Python Urllib2 + Beautifulsoup
So I'm struggling to implement beautiful into my current python project, Okay so to keep this plain and simple I'll reduce the complexity of my current script. Script without Beaut
Solution 1:
Regarding your last code snippet:
from bs4 importBeautifulSoupas soup
web_soup = soup(urllib2.urlopen(url), 'html.parser')
main_div = soup.find_all('td', {'align':'right'})[4]
You should call find_all on the web_soup instance. Also be sure to define the url variable before you use it:
from bs4 importBeautifulSoupas soup
url = "url to be opened"
web_soup = soup(urllib2.urlopen(url), 'html.parser')
main_div = web_soup.find_all('td', {'align':'right'})[4]
Post a Comment for "Python Urllib2 + Beautifulsoup"