I'm writing a web scraper using urllib2 and BeautifulSoup in python and am looking for a way to instruct python to click a button on a page that it reads the HTML source code for.
The following snippet of my script reads in URLs from a csv file and is meant to scrape data from the webpages specified, but an intermediary step is to click a "submit" button that exists on the webpage that is read from the csv's provided URLs.
for line in triplines:
FromTo = line.split(",")
From = FromTo[0].strip()
print(From)
To = FromTo[1].strip()
print(To)
url = KCString1 + From + KCString2 + To + KCString3
print(url)
page = urllib2.urlopen(url)
page_source = page.read()
soup = BeautifulSoup(page_source)
print(soup.prettify())
Is there a way to utilize urllib2 functionality in such a way as to say "follow the URL that is obtained from clicking this button"? I imagine I may need to find the JavaScript source to identify the button's identifiers first.