mercredi 15 juin 2016

searching a term in the main amazon website (parsing)

hey guys so amazons main search bar has the following information

<input type="submit" class="nav-input" value="Go" tabindex="7">

and I was thinking of creating a function that will look at amazon.co.uk and find this tag, and search any given keyword that I give

to do this, ive done this:

path = 'https://www.amazon.co.uk/'

values = {'s': 'what-I-want-to-search',
          'submit':'search'}
data = urllib.parse.urlencode(values)
data = data.encode('utf-8')


driver = webdriver.PhantomJS()
driver.get(path)
html = driver.page_source

driver = webdriver.PhantomJS()
driver.get(path, data)

html = driver.page_source

where myt thinking is that following a sentdex tutorial, I encode search terms and then send them to the html path, and ive been using selenium to combat dynamically loaded web pages but in this case i think it should be fine, but either way, I need to know how to get python to search something on the main site and have it take me to the search results page, any help ?

karma will come your way friends

Aucun commentaire:

Enregistrer un commentaire