Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium.webdriver.common.keys import Keys
- from selenium import webdriver
- import time
- import csv
- def main():
- browser= webdriver.Firefox()
- for i in range(1,2):
- temp_data=['Name','Sex','Age','Place','Availability','Facebook','Twitter','Soundcloud']
- write(temp_data)
- browser.get("https://www.sonicbids.com/find-musicians/?page_number="+str(i)+"&page_size=71")
- time.sleep(3)
- for j in range(1,73):
- try:
- all_detail=list()
- btn=browser.find_element_by_xpath('/html/body/div[4]/main/div/div/section/div/div[2]/ol/li['+str(j)+']/a[1]')
- btn=browser.find_element_by_xpath('/html/body/div[4]/main/div/div/section/div/div[2]/ol/li['+str(j)+']/a[1]')
- btn.click()
- time.sleep(2)
- name=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[1]/div/div/h1').text)
- place=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[1]/div/div/header/address').text)
- try:
- sex=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[1]/div/div/header/span[4]').text)
- age=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[1]/div/div/header/span[2]').text)
- except:
- sex=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[1]/div/div/header/span[2]').text)
- age='z Not-Specified'
- try:
- avail= browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[2]/div[1]/div/p[2]/span[2]').text
- except:
- avail='z Not-Specified'
- try:
- fb=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[2]/div[1]/div/ol/li[1]/a').get_attribute('href'))
- tw=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[2]/div[1]/div/ol/li[2]/a').get_attribute('href'))
- sc=(browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[2]/div[1]/div/ol/li[3]/a').get_attribute('href'))
- except:
- fb=browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[2]/div[2]/div/ol/li[1]/a').get_attribute('href')
- tw=browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[2]/div[2]/div/ol/li[2]/a').get_attribute('href')
- sc=browser.find_element_by_xpath('/html/body/div[4]/section/div/section/div[2]/div[2]/div/ol/li[3]/a').get_attribute('href')
- all_detail=[name,sex,age.split()[1],place,avail,fb,tw,sc]
- print(all_detail)
- write(all_detail)
- print(all_detail)
- time.sleep(2)
- browser.find_element_by_xpath('/html/body/div[4]/section/header/a/span').click()
- except:
- browser.refresh()
- browser.quit()
- def write(data):
- with open('music.csv','a',newline='\n') as csvfile:
- writer= csv.writer(csvfile, delimiter='~')
- writer.writerow([data[0]]+[data[1]]+[data[2]]+[data[3]]+[data[4]]+[data[5]])
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment