Python scrapy 爬虫问题 - 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
idotfish

Python scrapy 爬虫问题

  •  
  •   idotfish Apr 9, 2019 1996 views
    This topic created in 2591 days ago, the information mentioned may be changed or developed.
    用 scrapy 框架爬智联的招聘信息的时候报的错看不懂啊
    2019-04-09 23:29:10 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request
    2019-04-09 23:29:10 [selenium.webdriver.remote.remote_connection] DEBUG: POST http://127.0.0.1:50132/session/b97f6963939467e28aa83493fcf91f9d/url {"url": "https://zhaopin.com", "sessionId": "b97f6963939467e28aa83493fcf91f9d"}
    [7964:9720:0409/232912.471:ERROR:ssl_client_socket_impl.cc(964)] handshake failed; returned -1, SSL error code 1, net_error -100
    [7964:9720:0409/232912.505:ERROR:ssl_client_socket_impl.cc(964)] handshake failed; returned -1, SSL error code 1, net_error -100
    [7964:10376:0409/232913.146:ERROR:platform_sensor_reader_win.cc(242)] NOT IMPLEMENTED
    2019-04-09 23:29:14 [urllib3.connectionpool] DEBUG: http://127.0.0.1:50132 "POST /session/b97f6963939467e28aa83493fcf91f9d/url HTTP/1.1" 200 72
    2019-04-09 23:29:14 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request
    2019-04-09 23:29:14 [selenium.webdriver.remote.remote_connection] DEBUG: GET http://127.0.0.1:50132/session/b97f6963939467e28aa83493fcf91f9d/window_handle {"sessionId": "b97f6963939467e28aa83493fcf91f9d"}
    2019-04-09 23:29:14 [urllib3.connectionpool] DEBUG: http://127.0.0.1:50132 "GET /session/b97f6963939467e28aa83493fcf91f9d/window_handle HTTP/1.1" 200 111
    2019-04-09 23:29:14 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request
    2019-04-09 23:29:14 [selenium.webdriver.remote.remote_connection] DEBUG: POST http://127.0.0.1:50132/session/b97f6963939467e28aa83493fcf91f9d/element {"using": "class name", "value": "zp-search__input", "sessionId": "b97f6963939467e28aa83493fcf9
    1f9d"}
    2019-04-09 23:29:14 [urllib3.connectionpool] DEBUG: http://127.0.0.1:50132 "POST /session/b97f6963939467e28aa83493fcf91f9d/element HTTP/1.1" 200 102
    2019-04-09 23:29:14 [selenium.webdriver.remote.remote_connection] DEBUG: Finished Request



    这是代码
    class JobsSpider(scrapy.Spider):
    name = 'jobs'
    allowed_domains = ['zhaopin.com']
    start_urls = ['https://www.zhaopin.com/']

    def start_requests(self):
    browser = webdriver.Chrome()
    browser.get("https://zhaopin.com")
    windows = browser.current_window_handle
    input = browser.find_element_by_class_name('zp-search__input')
    input.send_keys('Python')
    time.sleep(1)
    button = browser.find_element_by_class_name('zp-search__btn')
    button.click()
    all_handles = browser.window_handles
    for handle in all_handles:
    if handle != windows:
    browser.switch_to.window(handle)
    url = browser.current_url
    yield Request(url,callback = self.parse)

    def parse(self, response):
    le = LinkExtractor(restrict_css='div.contentpile__content__wrapper__item.clearfix')
    for link in le.extract_links(response):
    yield scrapy.Request(link.url,callback=self.parse_job)

    def parse_job(self,response):
    jobs = JobItem()
    sel = response.css('div.main')
    jobs['jobname'] = sel.css('hi.l.info-h3::text').extract_first()
    jobs['Cname'] = sel.css('div.company 1::text').extract_first()
    jobs['salary'] = sel.css('div.l.info-money strong::text').extract_first()
    jobs['joblocation'] = sel.css('span.icon-address::text').extract_first()
    jobs['experience'] = sel.css('div.info-three.1').xpath('(.//span)[1].text()').extract_first()
    jobs['education'] =sel.css('div.info-three.1').xpath('(.//span)[2].text()').extract_first()
    jobs['count'] =sel.css('div.info-three.1').xpath('(.//span)[3].text()').extract_first()
    jobs['jobintro'] = sel.css('div.pos-ul').extract
    yield jobs

    这是不是和 cookie 有什么关系啊 求各位大佬解答
    Supplement 1    Apr 10, 2019

    class JobsSpider(scrapy.Spider): name = 'jobs' allowed_domains = ['zhaopin.com'] start_urls = ['https://www.zhaopin.com/']

    def start_requests(self): browser = webdriver.Chrome() browser.get("https://zhaopin.com") windows = browser.current_window_handle input = browser.find_element_by_class_name('zp-search__input') input.send_keys('Python') time.sleep(1) button = browser.find_element_by_class_name('zp-search__btn') button.click() all_handles = browser.window_handles for handle in all_handles: if handle != windows: browser.switch_to.window(handle) url = browser.current_url yield Request(url,callback = self.parse) def parse(self, response): le = LinkExtractor(restrict_css='div.contentpile__content__wrapper__item.clearfix') for link in le.extract_links(response): yield scrapy.Request(link.url,callback=self.parse_job) def parse_job(self,response): jobs = JobItem() sel = response.css('div.main') jobs['jobname'] = sel.css('hi.l.info-h3::text').extract_first() jobs['Cname'] = sel.css('div.company 1::text'.extract_first() jobs['salary'] = sel.css('div.l.info-money strong::text').extract_first() jobs['joblocation'] = sel.css('span.icon-address::text').extract_first() jobs['experience'] = sel.css('div.info-three.1').xpath('(.//span)[1].text()').extract_first() jobs['education'] =sel.css('div.info-three.1').xpath('(.//span)[2].text()').extract_first() jobs['count'] =sel.css('div.info-three.1').xpath('(.//span)[3].text()').extract_first() jobs['jobintro'] = sel.css('div.pos-ul').extract yield jobs 
    huisezhiyin
        1
    huisezhiyin  
       Apr 10, 2019
    你这个代码格式贴的 让人很难看得懂啊
    idotfish
        2
    idotfish  
    OP
       Apr 10, 2019
    @huisezhiyin 不好意思,刚刚入门 python,不太懂这些东西,把代码直接截图出来可以吗
    huisezhiyin
        3
    huisezhiyin  
       Apr 10, 2019   1
    @idotfish 你这随便搜一下 ERROR 就有答案啊
    随便搜一下 error:ssl_client_socket_impl.cc(964)] handshake failed
    stack overflow 上的一个答案
    https://stackoverflow.com/questions/37883759/errorssl-client-socket-openssl-cc1158-handshake-failed-with-chromedriver-chr
    不行的话就试试其他的答案
    About     Help     Advertise     Blog     API     FAQ     Solana     4290 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 78ms UTC 00:07 PVG 08:07 LAX 17:07 JFK 20:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86