Python + Jquery, crawl Java Tutorials Resource URLs on the West East web

Source: Internet
Author: User

#!/usr/bin/env python#-*-coding:utf-8-*-#@Date: 2018-06-15 14:01:45#@Author: Chenjun ([email protected];)#@Link: http://example.org#@Version: $Id $ fromPyqueryImportPyquery as Pqurl='http://xidong.net/File001/File_25266.html'Lis= []defGet_resource_lis (URL): Doc= PQ (Url=url, encoding='Utf-8') #响应头部没有声明编码类型, manual instructions are required, otherwise the captured data will be garbled in Chinese datas= Doc ('TR') #通过网页检查发现资源放在表格的tr中 Resource_lis=Datas.items ()returnLisdefMain (): Resource_lis=Get_resource_lis (URL) forSourceinchResource_lis:Print(Source.find ('a'). attr ('href') #取到每个tr中的a标签的href属性值, which is the address I need
if __name__=='__main__': Main ()
#后续可以存储到非关系型数据库中

Python + Jquery, crawl Java Tutorials Resource URLs on the West East web

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.