why doesn't this code print the <h3> tags in terminal? if(object2 == "y"): asking if…
Jump to turn (6)
- 1why doesn't this code print the tags in terminal? if(object2 == "y"): # asking i
- 2I added this code after the h3tags = soup.findall("h3"): h3tags = soup.findall("
- 3what does a parser do?
- 4I get the following error: AttributeError: 'NoneType' object has no attribute 't
- 5how do I change the parser?
- 6I changed the parser by using: soup = bs4.BeautifulSoup(queryresult.text, "lxml"
- User
why doesn't this code print the tags in terminal? if(object2 == "y"): # asking if user wants a recent search, then printing in terminal print("Complete a recent scrape on " + object + "? (y/n)\nAdds:\n'after:currentyear - 1'META TAG") recentSearchScrape = input("")
codeif(recentSearchScrape == "y"): def recentSearch(): recent_year = datetime.now().year - 1 query = object + " after:" + str(recent_year) webbrowser.open_new_tab(url + query) # Fetch the URL data using requests.get(url), # store it in a variable, query_result query_result = requests.get(url) soup = bs4.BeautifulSoup(query_result.text, "html.parser") # soup.find.all( h3 ) to grab # all major headings of our search result, h3_tags = soup.find_all("h3") # Iterate through the object # and print it as a string. for info in h3_tags: print(info.getText()) print("\n") print(h3_tags) print(soup) recentSearch()