推荐学习书目
› 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 · Jun 14, 2018 · 3927 views
    This topic created in 3031 days ago, the information mentioned may be changed or developed.
    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 replies  •  2018-07-16 11:44:02 +08:00
    cuzfinal
        1
    cuzfinal  
       Jun 14, 2018
    肯定是 58 更新了反爬策略呗。还有并不想看你的代码。
    beforeuwait
        2
    beforeuwait  
       Jun 14, 2018
    楼上+1
    JCZ2MkKb5S8ZX9pq
        3
    JCZ2MkKb5S8ZX9pq  
       Jun 14, 2018
    是有一点反爬,但不算严格。正在跑,稳得一比。
    jmjiafan
        4
    jmjiafan  
       Jul 16, 2018 via Android
    关键是电话号码的信息采集不到了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2440 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 15:15 · PVG 23:15 · LAX 08:15 · JFK 11:15
    ♥ Do have faith in what you're doing.