Selenium и Python - Как ждать добавления элементов к родителю на ленивой загрузке веб-страницы? - PullRequest
2 голосов
/ 08 июня 2019

Среди ожидаемых условий Selenium для ожидания (https://selenium -python.readthedocs.io / api.html # module-selenium.webdriver.support.expected_conditions ) Я не уверен, какое использовать, или если это то, что мне даже нужно.

Я пытаюсь получить отзывы по некоторым рецептам, например, на этой странице: https://www.foodnetwork.com/recipes/tyler-florence/a-gooey-decadent-chocolate-cake-recipe-2102926

Мне нужны все отзывы, поэтому я рекурсивно нажимаю кнопку «Показать больше», пока она не исчезнет.

В настоящее время я использую sleep(2) между рекурсиями для обеспечения загрузки следующего набора проверок, но это неэффективно, а в некоторых случаях недостаточно долго.

Заранее спасибо за любые указания.

1 Ответ

1 голос
/ 08 июня 2019

Чтобы извлечь все отзывы из рецепта на https://www.foodnetwork.com/recipes/tyler-florence/a-gooey-decadent-chocolate-cake-recipe-2102926, вы можете использовать следующее решение:

  • Кодовый блок:

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.common.exceptions import TimeoutException
    
    options = webdriver.ChromeOptions()
    options.add_argument('start-maximized')
    #options.add_argument('disable-infobars')
    options.add_argument('--disable-extensions')
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://www.foodnetwork.com/recipes/tyler-florence/a-gooey-decadent-chocolate-cake-recipe-2102926")
    myLength = len(WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div.gig-comment-body"))))
    while True:
        try:
            driver.execute_script("return arguments[0].scrollIntoView(true);", WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.gig-comments-more"))))
            WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.gig-comments-more"))).click()
            WebDriverWait(driver, 20).until(lambda driver: len(driver.find_elements_by_css_selector("div.gig-comment-body")) > myLength)
            reviews = driver.find_elements_by_css_selector("div.gig-comment-body")
            myLength = len(reviews)
        except TimeoutException:
            break
    for review in reviews:
        print(review.text)
    driver.quit()
    
  • Выход на консоль:

    I’m exited to try it, but it seems like a hit or miss kind of situation.
    I wish I had read the reviews in this cake. It was a mess. It was too liquidy and overflowed 1/2 way through baking. I had to throw both cakes(liquid way) and clean out my oven. Something is wrong with the portions or cake pan size in the recipe.
    Beyond disappointed! I have loved to bake for 20 years now and have had very few baking disasters. I followed the recipe and put the pans in the oven. About 15 min. into the baking time, the batter was overflowing onto the bottom of the oven. I did the best I could to clean it up while not disrupting the cooking temp. I let the cakes finish cooking the recommended time, but when I took them out half of the pan was cooked too much while the other half was somewhat liquid. I have NO idea as to how it went so badly.
    I've been making this cake since I was 13 (when the episode aired), and now, in my early 20s, I use this recipe for my nieces' and nephews' birthday cakes. It sounds like the reviewers here were expecting the sponge itself to be 'gooey and decadent,' but the beauty of this recipe is the frosting -- if you get it right. I can imagine the average home cook not being able to get the temperatures of everything correct; the butter can't be too soft, the chocolate can't be too hot. But when it's right, it is, indeed, the gooiest, most decadent buttercream (note: buttercream) for a light, airy sponge.
    I have made this cake twice now and both times it has crumbled and basically fell apart. Though rich and decadent, a cake should hold and not crumble under the weight of frosting. The frosting is too sweet and barely covers the cake. This is not the caliber of quality I have come to expect from Tyler Florence. I won't be making it again.
    Can anyone tell me how much is 1 1/2 stick of unsalted butter in weight?
    In the US, one stick of butter is 4 ounces, so 1 1/2 sticks would be 6 ounces.
    I only made the cake and not the frosting. It was an adequate chocolate cake, but I went down on the rating because it's title "gooey and decadent" and its really neither of those things. It's acceptable at best. I also had to add about double as much melted chocolate and added some cocoa powder to bump up the chocolate flavor. In my oven, it took way longer than 30 minutes to bake. I eventually put the oven at 375 and baked for about 40 minutes.
    One of the best chocolate cakes I have ever baked. I used excellent quality dark chocolate for the cake and the same for the icing. My guests couldn't get enough. BUT it is VERY rich!
    My honey baked this for me and wrote out for the quotes from a love poems call the River. It was so unexpected!
    I Love this recipe, the cake is so good
    I'm a home baker, bake daily and think I'm ok at reading recipes. Read some reviews, and I used regular ap flour. Cake flour is very soft and apprently makes this little cake fall apart. It's the corn starch in the flour.
    I'm pretty sure the frosting is so sweet because unsweetened chocolate is meant to be used with the powdered sugar, I did, and it's a nice frosting, nothing special.
    I usually make a swiss or italian buttercream, but I did like the Chamboard on the cake and added 2 tbsp to the frosting as well.
    It's a nice easy cake and if you like chocolate, you'll like this
    The chocolate cake itself was terrific. Light, moist, flavourful, although I used all purpose flour instead of cake flour. It still was great. The icing, however, wasn't what I expected. I read the reviews before I tried this recipe; I now see what most people were talking about with regards to the icing. The consistency was thin and runny and I used 2 1/2 cups of powdered sugar instead of 3 cups and it was still too sweet. Also, the amount of icing wasn't sufficient to cover the entire cake after filling (I used a 9x3" cake pan instead of 2x9" pans. I could only use the icing as a filling and use another icing to frost the cake. Despite this setback, like I said previously, the cake itself was great.
    Baked this cake for my father's birthday. So tasty. I used all purpose flour which worked just fine. I didn't have two cake tins of the same size, so I used one big one, and thought I would cut it through the middle. The baking time increased to 60 minutes, and when I tried to slice it through the middle, the top part of the cake crumbled into 4 pieces. I was able to save it by covering it up with the butter cream. Also I didn't have any raspberry liqueur so I put a thin layer of raspberry preserve in the middle with the butter cream. It worked well. I used to suggestion of the previous reviewers and halved the quantity of sugar in the icing. All in all, a very tasty cake. Moist, crumbly and slightly chewy. Loved it! Will definitely use this recipe again!
    My family begs for this recipe on special occasions. But here are the tricks I have learned from the reviews and my own little experiments: DO NOT USE cake flour. All purpose works best. Bake longer, cool longer. If your cake falls apart slightly, use your frosting as the glue. I followed a recipe in one of the reviews "where your wife was the genius" and made a whipped cream frosting and folded the featured frosting into that. I also sprinkled that with bit of Chambord to give the cake a kick of the raspberry. Then I tried to do "shavings" but my hands may have melted the chocolate a little too much to make it work. Thus, I chopped that part too with a large knife. All in all, I owe my success to this recipe to the reviews, Tyler and that genius wife of one writer.
    My cake turned out to be very light and fluffy, not at all gooey (which is what I was hoping for). I didn't use any Chambord, since the kids would be eating the cake with us. I don't think this would have made a difference though in the gooey-ness factor.
    
    The buttercream recipe just barely covers the cake, so frost it sparingly. I thought the frosting was too sweet as well and will cut back on the powdered sugar if I make this cake again. I think I will also use cocoa powder rather than melted chocolate to increase the chocolaty flavor.
    It is a gooey and decadent chocolate cake! This is now my "go to" chocolate cake recipe. *I did reduce the powdered sugar in the buttercream - it's too sweet for my taste.
    
    You've done it again, Tyler!
    Loved this one!!! I changed a few things like the amount of chocolate to the batter, a raspberry simple syrup for the filling and added macadamia nuts to the side. My entire family loved it!
    Before I made this cake I read the reviews and had the complains in mind when I mixed all the ingredients together. To fix the lack of chocolate taste I added about 4 heaping spoonfuls of cocoa powder (each spoonful was about 2 1/2tbsp, about 2 1/2oz more of the melted chocolate, and about 4 tbsp of water to keep the consistantcy right. The baking time took roughly 10 minutes longer that what the recipie states. As for the 'buttercream frosting', it was WAY to sweet and the 'frosting' had a very loose and almost runny consistantcy compared to the other buttercreams I have made in the past. Overall, the cake gets a 4 because after I made the adjustments I was left with a moist and light cake with a lovely chocolate flavor, but the 'frosting' gets a 1, my suggestion is to use a different icing this one is a bust. Hope this helps!
    can anyone taste the raspberry???
    I have to say I'm not a big fan of the cake recipe, but I love the frosting.
    
    I just wish that for baking, they'd use weight instead of volume. It would make for much better and consistant results.
    I think the baking time is wrong. The cake tested baked with toothpicks, after 35 minutes, but when I took it out of the oven, it totally collapsed.
    
    The chocolate flavor was poor , and that is after using high quality chocolate
    .
    I am wondering if there are mistakes with the editing of this recipe.
    
    
    
    .
    Should one find oneself in the following situation where you have spring form pans versus the standard fair cake pans and cook this cake as prescribed....I would like to call the result UNDRESSING TYLER:
    
    Take said cake and crumble up like you do cornbread for dressing..add 1 stick of butter, 2 eggs, a cup (or looks right) of buttermilk and a splash of vanilla and mix this all up in a nice oooowee batter and put into a 9x12 greased baking pan and cook for 25-30 minutes at 350. You will have a divine concoction of a browny....ice with choclate buttercreme...
    
    SO The Nakid Tyler brownies were a success for My Mom's Church event...
    
    All the best and keep cooking
    I followed the recipe without any trouble. Mind you, I'm not a good cook anyway but this turned out like magic! Everyone loved the cake, even without the Chocolate Chip Butter Cream. Luckily, the semisweet dark chocolate I had available came with hazelnuts, which after baking and with chocolate, tasted wonderful!
    
    The steps and ingredients were accurate.
    
    I definitely recommend using dark chocolate with hazelnuts for this recipe. Otherwise, it's perfect by itself!
    
    Tyler, you rock!!!
    I made this cake yesterday for my daughter's birthday. I used a bundt pan as well, added 1/2 cup of cocoa powder, and baked an extra 15 minutes. Turned out perfect. My frosting came out very soupy, so I drizzled it on the cake pieces after putting them on plates. Fabulous, and rave reviews!
    This cake was really delicious. I didn't use the raspberry liquor and it still was great. I didn't really care for the icing, though, I ended up having to use more butter than in the recipe and it still was very thin. The cake is perfect though, one of the best.
    I make this cake often and will be making it for Thanksgiving. It's always a crowd pleaser!
    I absolutely LOVE this cake. I have been making it for birthdays, holidays and special occasions for 5 years now. It is moist and light, not super chocolatey.....perfect
    Everyone in our family requests this cake for their birthday. It is awesome! It is both decadent and moist. Well worth the effort and trouble. The icing tastes like homemade fudge.
    I made this cake for my family yesterday . Although I had read some disappointing reviews I thought, hey I can cook better than they can - so I made it anyway. I made it in two pans as recommended. I think other cooks had made it in one pan - hence the falling or undercooking problem. I cooked the two cake pans for 35 minutes. However there was not enough chocolate flavour in the batter, so I too added cocoa powder - as suggested by other reviewers. The cake looked perfect but unfortunately did not deliver on taste. It lacked intense chocolate flavour and can hardly be called decadent. I won't make this cake again or recommend it to anyone. I am now on a quest to find the ulitimate chocolate cake.
    I read all the reviews because I am new to baking. However, I used a bunt pan because of the middle of the cake being too soft. I also used regular flour. The cake did end up being too soft after baking for 40 min so I baked it for another 20 min. I also added 1/2 cup of Coca Powder. It was great, not too sweet for my husband. I also made a butter cream icining. It was a hit!!!
    I am not much of a baker, but had great luck with this cake and it was delicious. It is a sweet cake.
    Recommend making sure ingredients are cool to avoid melting issues. Also use ice cold water in cake batter for good success. Cake cooks longer than 30 minutes. more like 40-45
    I made this cake for a Mothers Day get together and now my family is begging me to make more. First problem to address is the cake falling, I did not have a problem with this and the only thing I can attribute it to is that I used non-stick 9" cake pans with the bottom lined with parchment paper like Tyler did on the show. The cake is very light so the way you put it in the pan is the way it will come out so spread it in evenly. I know that when I bake a normal cake I put more batter to the outside of the pan because the middle rises so much, but this cake is different so it must be even before baking. Also, do not open the oven at all until you are ready to test the center and be quick about testing it, the cake is so light that heat loss could make the structure fall. Even after it cools all the way it will be difficult to work with because it is so light. Run a butter knife or a metal spatula around the sides before attempting to take it out of the pan and just be gentle. Now the icing, when I made it the first time I also did not like the consistency and my culinary genius wife suggested we fold it into some whipping cream and 'Viola!' it came out perfect. First fill a large mixing bowl with ice water and put a smaller metal bowl inside and let it chill for a few minutes. Then take a pint of heavy whipping cream in the cold metal bowl and beat it with a whisk (hand or electric) while adding about 1/2 cup of powdered sugar. Whip until stiff peaks form and then gently fold the cooled icing mixture and chocolate bar pieces into the whipped cream. Don't overfold or you'll wreck the structure of the whipped cream. Spread icing and enjoy. If you have any questions please email me at theirishson@yahoo.com under the heading 'CAKE' and I'll try to help as best I can.
    This cake was very delicious, not too rich. It was pretty fluffy and baked well, though we had a bit of a problem with it slightly collapsing. It may not have looked good, but it tasted good and there were no complaints.
    I just watched the program which I had recorded and I found the problem with the icing! On the program Tyler uses 4 oz. UNSWEETENED chocolate, melted and cooled, but in the recipe it instructs to use "dark chocolate" which implies that it is sweetened. This along with the powdered sugar would make the icing too sweet. In addition, it's probably a good idea to beat the mixture well after the melted and cooled unsweetened chocolate is added before incorporating the butter, because if the mixture is too warm from the hot water and the warm chocolate, it will melt the butter as it's added, and the icing will be thin and runny. If the mixture is thoroughly cooled (and mixing it well will help this along) then adding the butter in small bits will thicken it up and help to create a nice spreadable consistancy. Help this helps anyone who was unhappy with the icing.
    This was dissapoiting considering the work involved. Sweeter than it was chocolatey
    Tyler, I was disappointed. And I love most of the stuff you cook. But this one missed the mark. The icing turned out hard at the end of the first day. The cake sank in the middle...and I followed the recipie to the letter...the only thing different...I added 1 tablespoon of cocoa powder to the cake batter, as it did not seem chocolatey enough. I was really disappointed in the icing. I was looking for a creamy buttery tasting icing that was soft and luscious. Instead it was dry, hard and sugary. I'm still searching for the ultimate. The cake may be good to some, but for a foodie like myself, I am still looking for the ultimate chocolate cake.
    I read all the reviews and was hoping the end result would be somewhere in between. I was really disappointed. The cake came out 'clean' on the toothpick after 35 minutes, but it sank in the middle while cooling and came apart when I removed it from the pan. Adding frosting was a nightmare, and this frosting in particularly tastes like pure sugar. It probably needs more melted chocolate. I would find another recipe and heed people's warnings. It may taste okay to die-hard chocolate-sugar fans, but it's definitely not 'the ultimate.'
    check out the recipe for chocolate cake on the back of the Hersheys Cocoa Powder can.
    I have made this cake many times and everyone always raves, but, I usually use regular flour, the one time I used cake flour it was to crumbly. It also seems to set better with the regular flour. I make the Hershey's frosting off the back of the cocoa tin and it is not to sweet. This is the cake my family always asks for on their birthdays, it has become a family favorite.
    Hey Tyler,
    
    Your cake sucks. It falls in the middle, the frosting does not come together and is too sweet, and the whole thing turns into a gooey sewage when completed. Thankfully my guests were too polite to complain. Thanks for a ruined evening.
    If you love chocolate cake, this is the one to make!!! Just be sure to use 2 cake pans cause it makes a lot of batter and will spill over if you use a 9x13 pan. The cake is fabulous!!! The icing is TOO sweet. Next time I am going to cut it down to 1 1/2cup powdered sugar in the buttercream. Can't eat it otherwise.
    Kids comments were it was the best chocolate cake they've ever had. No doubt it was delicious. Don't forget the parchment paper. I did so it wasn't a visual beauty (cake stuck some to the pans). But that didn't bother anyone. I'd also agree more time might help.
    Delicious! People couldn't believe I cooked such a yummy cake and so easily!
    Oh my goodness this cake will be fun to make and eat. Tyler Florence is a great cook. Thanks for the recipes!
    The cake was tasty, but 40 minutes wasn't long enough more my cake to cool. The frosting melted all over leaving a gooey, yet still tasty mess.
    This is the best chocolate cake I have ever tasted better yet, made myself. The first time I made this cake it was eaten that night I had to make another cake the following day just to have a whole slice.
    This cake is good but with a name of "Gooey, Decadent Chocolate Cake" I expected a little more chocolatey. It is improved with the frosting although I added a 1/4 cup of cocoa to the frosting. I agree with others that it falls slightly in the middle and the cake puffed up over the edge of the pan (making it a bit more difficult to remove). Also, don't skip the part of lining the bottom of the pan with parchment. I was out of parchment so greased and floured the pan instead and that was not enough!
    Wow! I know this wasn't advertised as a Devil's Food Cake, but mine came out slightly red in color, extravagantly light and airy with rich chocolate flavor. My husband grew up eating only packaged foods, so he very much favors boxed cakes over homemade. This cake has won him over for it's texture and flavor. BRAVO to Tyler for creating the perfect way to cheat those who will only eat boxed:)
    The BEST chocolate cake I have ever had.
    This cake was very moist - but I found it to be somewhat crumbly and not as chocolatey as I prefer my cakes to be. I made it with peanutbutter icing instead of the buttercream. Overall it was ok, but I probably won't make it again.
    Fantastic - I fed this cake to five of my chocoholic friends and they could not get enough of it. They ate the entire cake at one meal. I followed the directions to the tee. I also sifted the cake flour before measuring it. For me this recipe made just enough batter to fill two 9" cake pans halfway. If I had filled them anymore, they would have overflowed during baking. The icing was a bit thin, but I worked with it; and by itself, the icing is very sweet, but paired with the cake is perfect. Have faith in Tyler; this recipe is one of the new favorites of my chocoholic bunch.
    This recipe is a disaster. The cake batter had to be divided between three cake pans, rather than two. The frosting was also awful... way too sweet. Tyler's recipes are usually great, so I'm wondering what happened with this one.
    
    The cake itself, however, tastes great. Just don't use the buttercream recipe!
    Having looked over many reviews, it seemed like some people had problems with overflow/too much batter (probably used too shallow a pan), sticking to the pan (I used silicone bakeware and a parchment round - and had no problems), and "caving in" - in which case, I think too much flour was accidentally used, or perhaps the oven was not the temparture it claimed to be.
    
    I did sift THEN measure the flour, used nice deep silicone bakeware and double checked oven temp with an independent thermometer. The results were a rich, firm cake of very moist crumb, no trouble with removal from the pan, and a perfectly rounded top. It was not gooey at all, but it is a cake of incredible tenderness and flavor.
    
    This is a very good recipe, it was a birthday cake and it turned out perfectly. I did not use the frosting recipe, in favor of a simple vanilla buttercream.
    
    This one's a keeper!
    Great flavor, but I had similar problems with it sinking in the middle. It looked like a mess, but sure tasted incredible!
    cake was excellent. the frosting is sweet but perfect combo with the cake. will definetly make again and again.
    This was a good cake, in general. The cake itself is rather crumbly/delicate, but the frosting made it very, very yummy!
    I made the cake for my wife's birthday and it was outstanding. Mine turned out very moist and rich - even after returning it to the oven twice to get the toothpick clean. I thought that the Chambord drizzle added something but I was conservative with how much.
    
    There must be something wrong with the proportions of water to sugar for the icing. As others have suggested, it was too thin. I added about 3/4 cup more sugar -- but next time I will cut back on the water instead.
    
    The cake batter itself is more than needed to fill the 2-9" pans 2/3rd's as is directed. But I had NO runover in the oven -- but DID have leftover batter.
    I'm a chocolate fan and found this to be almost too rich for me. It was a big hit, gave some to a friend who ate 3 large pieces in one sitting. Takes some time to prepare but worth the effort!
    This was the most delicious cake I've ever made and everyone loved it. I couldn't find parchment paper anywhere so the cake fell apart and the frosting needed a little more powdered sugar for consistency, but all in all, the cake was absolutely luscious!
    Tyler, please come clean my oven.
    I thought it was fairly simple to make.
    Everyone loved it!
    Nice and moist but not as chocolatyyy as I wanted or was expecting. The frosting was surprisingly thin but firmed up nicely. Goes great with fresh whipped cream.
    cake was super frosting perfect everything came together following recipe to the letter cant wait to make it again oh my adjustment is 70 or 85 percent cocoa lindt is my fav
    Our family thought this cake was delicious. I took the time to read the reviews before selecting this cake. Thank you everyone!! The tip for three pans was very important and worked wonderfully. Also I didn't waste time trying the frosting recipe that was included but found another another chocolate butter cream recipe to use from food network. Even that recipe needed some changes. Our family enjoyed 2 sticks of butter and 2 cups of powered sugar with 3 tablespoons of milk and 1 teaspoon of vanilla and some melted chocolate. Thank you so much for helping me make a wonderful Valentine's cake!
    This is a delicious, moist chocolate cake. . . . . .one of the best I've tried. However, the batter is indeed way too much for two pans and created a huge mess for me too. The icing tasted awful and was quite runny before I modified it. I decided to scrap the icing and used a chocolate cream cheese icing recipe instead. Delicious!
    It's what it says-Gooey and Decadent. Easy to make, very nice rich flavor, but there is way too much batter for 2 9" cake pans. The recipe calls for filling the pans 2/3 full. I knew my pans were filled to nearly the top and, sure enough, they overflowed into the oven and made a horrible mess. I put a cookie sheet under the pans to catch the overflow. This recipe needs 3 9" cake pans, not 2. The rest of the recipe is perfectly fine.
    chocolately yummy
    The cake is excellent--not really gooey, but very flavorful with great chocolate taste.
    
    The buttercream, however, is far too sweet. I tasted it before putting on the cake, fortunately, and used it VERY sparingly. If I had to do it over again, I would keep the chamboard and add a little apricot preserve between the layers, and top with whipped cream.
    I love the taste BUT both times I made this cake it rose up over the pans and was so soft and tender it started falling apart.
    The icing needed some modifications. I will not bake it again b/c of these problems.
    This cake is really easy to make...even better with an extra 1/2 cup unsweetened cocoa powder in the cake and 1/4 in the frosting. Just like Grandma used to make!
    A hit with our friends! It was incredibly moist, and the frosting was so good!
    
...