Python,为obj抓取一个网站

2024-09-26 17:53:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在写一个程序怪物网站找工作并打印出所有的职位。当我运行它时,它什么也不打印,所以我添加了一个列表范围(现在被注释掉了)以查看列表是否正在填充。不是的。请告诉我我做错了什么。在

这是密码。我是python新手,但对我来说这应该可以。在

提前谢谢。在

    #! /usr/bin/python
import re
import requests
from urllib import urlopen
from BeautifulSoup import BeautifulSoup

webpage = urlopen("http://jobsearch.monster.com/search/Engineer_5?q=Software&where=AZ&rad=20&sort=rv.di.dt").read()

listIterator = []
#listIterator[:] = range(1,50)

soup = BeautifulSoup(webpage)

titleSoup = soup.findAll("title")

for i in listIterator:
    print titleSoup[i]
    print "\n"

raw_input("Press enter to close: ")

Tags: fromimport程序密码列表网站职位urlopen
1条回答
网友
1楼 · 发布于 2024-09-26 17:53:26
from urllib import urlopen
from BeautifulSoup import BeautifulSoup

handle = urlopen("http://jobsearch.monster.com/search/Engineer_5?q=Software&where=AZ&rad=20&sort=rv.di.dt")
responce = handle.read()
soup = BeautifulSoup( responce )

job_urls = soup.findAll(name = 'a', attrs = { 'class': 'jobTitle fnt11_js' })
for job_url in job_urls:
    print job_url.text
    print

相关问题 更多 >

    热门问题