V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
koekoekoe
V2EX  ›  Python

58 同城爬虫出了问题只爬了几十条数据,以前能上千条的

  •  
  •   koekoekoe · 2018-06-14 15:15:25 +08:00 · 2678 次点击
    这是一个创建于 2142 天前的主题,其中的信息可能已经有所发展或是发生改变。
    import ...

    def get_links():
    urls = []
    for page in range(1, 71):
    list_view = 'http://sz.58.com/tech/pn{}'.format(page)
    url_1 = 'http://sz.58.com/tech/'
    url_2 = 'x.shtml'
    wb_data = requests.get(list_view, headers=headers)
    soup = BeautifulSoup(wb_data.text, 'html.parser')
    for link in soup.select('div.job_name a'):
    urls.append(url_1+str(link.get('urlparams').split('=')[-1].strip('_q'))+url_2)
    return urls


    def get_info():
    urls = get_links()
    try:
    for url in urls:
    wb_data = requests.get(url, headers=headers)
    soup = BeautifulSoup(wb_data.text, 'html.parser')
    time.sleep(2)
    data = {
    'job': soup.select('.pos_title')[0].text,
    'salary': soup.select('.pos_salary')[0].text,
    'condition': soup.select('.item_condition')[1].text,
    'exprience': soup.select('.item_condition')[2].text
    }
    print(data)
    except IndexError:
    pass
    except requests.exceptions.ConnectionError:
    pass

    get_info()
    4 条回复    2018-07-16 11:44:02 +08:00
    cuzfinal
        1
    cuzfinal  
       2018-06-14 17:00:19 +08:00
    肯定是 58 更新了反爬策略呗。还有并不想看你的代码。
    beforeuwait
        2
    beforeuwait  
       2018-06-14 17:05:42 +08:00
    楼上+1
    JCZ2MkKb5S8ZX9pq
        3
    JCZ2MkKb5S8ZX9pq  
       2018-06-14 18:20:49 +08:00
    是有一点反爬,但不算严格。正在跑,稳得一比。
    jmjiafan
        4
    jmjiafan  
       2018-07-16 11:44:02 +08:00 via Android
    关键是电话号码的信息采集不到了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1427 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 23:52 · PVG 07:52 · LAX 16:52 · JFK 19:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.