我想用BeautifulSoup
在我的领域中以批处理模式搜索作业。我会有一个网址列表,全部由雇主职业网页组成。如果搜索在职务中找到关键字GIS
,我希望它返回到招聘公告的链接。在
我将给出一些案例:
第一个公司网站需要关键字搜索。这一页的结果是:
https://jobs-challp.icims.com/jobs/search?ss=1&searchKeyword=gis&searchCategory=&searchLocation=&latitude=&longitude=&searchZip=&searchRadius=20
我希望它返回以下内容:
https://jobs-challp.icims.com/jobs/2432/gis-specialist/job
https://jobs-challp.icims.com/jobs/2369/gis-specialist/job
第二个站点不需要关键字搜索:
https://www.smartrecruiters.com/SpectraForce1/
我希望它返回以下内容:
https://www.smartrecruiters.com/SpectraForce1/74966857-gis-specialist
https://www.smartrecruiters.com/SpectraForce1/74944180-gis-technician
就我所能得到的:
from bs4 import BeautifulSoup
import urllib2
url = 'https://www.smartrecruiters.com/SpectraForce1/'
content = urllib2.urlopen(url).read()
soup = BeautifulSoup(content)
text = soup.get_text()
if 'GIS ' in text:
print 'Job Found!'
有两个问题:
1.)这当然会返回找到作业的确认,但不会返回作业本身的链接
2.)对于第一个公司现场,未使用此方法找到两个相关职位。我通过扫描soup.get_text()
的输出进行检查,发现它在返回的文本中不包含职务。在
如有任何帮助或其他建议,我们将不胜感激。在
谢谢!在
这是我的尝试,但和上面差不多:
它定义了一个函数“work()”来完成实际的工作,从远程服务器获取页面;使用}元素(链接),并检查每个链接的文本中是否有“GIS”,如果是,那么它将打印链接的
urlopen()
,因为它看起来像您想要使用urllib2
,但我建议您使用Python-Requests;然后它使用findAll()
查找所有的{href
属性。在然后它使用list comprehension定义URL列表(本例中只有2个URL),然后为列表中的每个URL运行
work()
函数,并将其作为参数传递给函数。在开始吧!在
此代码将查找所有包含“GIS”字符串的链接。我需要添加
&in_iframe=1
以使第一个链接正常工作。在输出:
^{pr2}$有一种方法:
如果您现在运行此程序,它将打印:
^{pr2}$相关问题 更多 >
编程相关推荐