Skip to content

Instantly share code, notes, and snippets.

@saml
Created May 20, 2014 01:47
Show Gist options
  • Save saml/588250ed46a1ed722c90 to your computer and use it in GitHub Desktop.
Save saml/588250ed46a1ed722c90 to your computer and use it in GitHub Desktop.
from selenium import webdriver
def search_alibaba(term):
'''Searches alibaba site and returns the seller company
name and websites'''
company_info = []
term = term.replace(" ", "_")
browser = webdriver.Firefox()
browser.get('http://www.alibaba.com/corporations/'+term+'/1.html')
links = browser.find_elements_by_xpath("//a[@class='cd dot-company']")
urls = [link.get_attribute('href') for link in links]
for url in urls:
browser.get(url)
for x in browser.find_elements_by_xpath("//tbody/tr[3]/td/a[@class= 'mc-click-target']"):
print(x.get_attribute('href'))
browser.quit()
search_alibaba('bag')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment