Import requests/beautifulsoup problem - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Import requests/beautifulsoup problem (/thread-35706.html) |
Import requests/beautifulsoup problem - Jokadaro_ - Dec-04-2021 Hey everyone, Since yesterday I've been trying to solve a problem from Practicepython.org (exactly the 17), that needs to import requests and beautifulsoup and installing them with pip. I dont get exceptions in the code, but i get nothing, I sucefully installed pip, and then requests and bs4, after trying to make it work for a few hours I tried to copy their solution to see if it works as it should, but it doesnt (i think). This is the image of my IDLE. Today I checked again on pip, updated it, and tried to install again requests and bs4. I don't know what I'm doing wrong. https://imgur.com/a/b9rbFeR [attachment=1432] Thanks to all of you in advance. RE: Import requests/beautifulsoup problem - snippsat - Dec-04-2021 Post code in code tag,can not test code if post image. Looking at this so has site changed the css tag. import requests from bs4 import BeautifulSoup base_url = 'http://www.nytimes.com' r = requests.get(base_url) soup = BeautifulSoup(r.content, 'html.parser') for story_heading in soup.find_all(class_="css-eylb5n e1lsht870"): if story_heading.a: print(story_heading.a.text.replace("\n", " ").strip()) else: print(story_heading.contents[0].strip())
RE: Import requests/beautifulsoup problem - Axel_Erfurt - Dec-04-2021 Please don't post images. Post your code (with button insert python) and the error message (with button Insert output) snippsat was faster RE: Import requests/beautifulsoup problem - Jokadaro_ - Dec-05-2021 I see, now it works right! Thank you very much to you 2, and I'm sorry for the image, this was my very first post, have a nice day! |