Created
May 20, 2014 01:47
-
-
Save saml/588250ed46a1ed722c90 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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