请帮忙。 我想得到每一页的所有公司名称,它们有12页。你知道吗
http://www.saramin.co.kr/zf_user/jobs/company-labs/list/page/1http://www.saramin.co.kr/zf_user/jobs/company-labs/list/page/2 --本网站只更改号码。你知道吗
这是我目前的代码。 我能得到12页的标题(公司名称)吗? 先谢谢你。你知道吗
from bs4 import BeautifulSoup
import requests
maximum = 0
page = 1
URL = 'http://www.saramin.co.kr/zf_user/jobs/company-labs/list/page/1'
response = requests.get(URL)
source = response.text
soup = BeautifulSoup(source, 'html.parser')
whole_source = ""
for page_number in range(1, maximum+1):
URL = 'http://www.saramin.co.kr/zf_user/jobs/company-labs/list/page/' + str(page_number)
response = requests.get(URL)
whole_source = whole_source + response.text
soup = BeautifulSoup(whole_source, 'html.parser')
find_company = soup.select("#content > div.wrap_analysis_data > div.public_con_box.public_list_wrap > ul > li:nth-child(13) > div > strong")
for company in find_company:
print(company.text)
那么,您想删除所有
headers
,只获取公司名称的string
? 基本上,您可以使用soup.findAll
以如下格式查找公司列表:然后使用
.find
函数从<span>
标记中提取信息:之后,使用
.contents
函数从<span>
标记获取字符串:因此,您可以编写一个循环来对每个页面执行相同的操作,并创建一个名为
company_list
的列表来存储每个页面的结果并将它们附加在一起。你知道吗代码如下:
company_list
将为您提供所需的所有公司名称我终于明白了。谢谢你的回答!你知道吗
image : code captured in jupyter notebook
这是我最后的密码。你知道吗
相关问题 更多 >
编程相关推荐