【发布时间】:2020-10-14 21:46:57
【问题描述】:
我正在尝试为通过 Indeed.com 解析的朋友制作一个网络爬虫,以帮助招聘工作。基本上他想抓取页面并创建一个包含所有职位列表的 csv 文件,包括职位、公司和职位描述。我目前卡住了,这就是我所拥有的:
from selenium import webdriver
from bs4 import BeautifulSoup
import requests
driver = webdriver.Chrome()
driver.get('https://indeed.com')
searchBox = driver.find_element_by_xpath('//*[@id="text-input-what"]')
searchBox.send_keys('Social Media Marketing')
searchButton = driver.find_element_by_xpath('//*[@id="whatWhereFormId"]/div[3]/button')
searchButton.click()
import time
time.sleep(5)
popUpButton = driver.find_element_by_xpath('//*[@id="popover-x"]/button/svg')
pupUpButton.click()
print(driver.current_url)
r = requests.get(driver.current_url)
print(r.text[0:10500])
soup = BeautifulSoup(r.text, 'html.parser')
results = soup.find_all('span', attrs={'class':'company'})
关于我应该如何处理这个问题有什么建议吗?
【问题讨论】:
标签: python selenium beautifulsoup