摘要: 1 """电影天堂爬虫""" 2 3 4 import requests 5 from lxml import etree 6 7 BASE_DOMAIN = 'https://dytt8.net/' 8 HEADERS = { 9 'User-Agent': 'Mozilla/5.0' 10 } 阅读全文
posted @ 2020-06-11 01:19 udbful 阅读(409) 评论(0) 推荐(0)
摘要: 1 """豆瓣电影爬虫""" 2 3 4 import requests 5 from lxml import etree 6 7 # 1、将目标网站上的页面爬取出来 8 headers = { 9 'User-Agent': 'Mozilla/5.0', 10 } 11 12 url = 'htt 阅读全文
posted @ 2020-06-10 01:41 udbful 阅读(138) 评论(0) 推荐(0)
摘要: 实现: # 1、获取所有tr标签# 2、获取第2个tr标签# 3、获取所有class等于even的tr标签# 4、获取所有a标签及其属性值# 5、获取所有的职位信息(纯文本) 1 """lxml&XPath结合使用""" 2 3 4 from lxml import etree 5 6 parser 阅读全文
posted @ 2020-06-09 16:49 udbful 阅读(302) 评论(0) 推荐(0)
摘要: 一、lxml库解析字符串 """lxml库解析html代码""" from lxml import etree text = """ <body> <div class="header clear"> <div class="inner"> <h1 class="logo_area" title=" 阅读全文
posted @ 2020-06-09 15:18 udbful 阅读(344) 评论(0) 推荐(0)
摘要: 一、安装 XPath安装(在chrome右上角找到选项--》更多工具--》扩展程序。把crx文件拖拽,即可安装) 二、基本语法 https://www.w3school.com.cn/xpath/index.asp 阅读全文
posted @ 2020-06-09 11:28 udbful 阅读(445) 评论(0) 推荐(0)
摘要: 以下案例只对登录不需要验证码登录的网页才有效 1 """""" 2 3 4 # 大鹏主页:dapeng_url = "http://www.renren.com/880151247/profile" 5 # 人人网登录login_url = 'http://www.renren.com/PLogin 阅读全文
posted @ 2020-06-08 23:13 udbful 阅读(338) 评论(0) 推荐(0)
摘要: 1、requests之get()方法 https://www.cnblogs.com/sruzzg/p/13041898.html 类似 1 """requests之get()方法""" 2 3 import requests 4 5 # response = requests.get('https 阅读全文
posted @ 2020-06-08 15:47 udbful 阅读(262) 评论(0) 推荐(0)
摘要: 1、保存cookie信息 1 """保存cookie信息""" 2 3 4 from urllib import request 5 from http.cookiejar import MozillaCookieJar 6 7 cookieFilename = 'cookie.txt' 8 # 声 阅读全文
posted @ 2020-06-08 11:36 udbful 阅读(306) 评论(0) 推荐(0)
摘要: 有些网站没有登录无法访问页面,登录后就可以访问。如人人网 所有程序要模拟登录状态,方法有手动方法和使用帐号密码自动登录方式。本篇使用手动复cookie请求要访问的网页,并把请求到网页保存到本地 1 """使用手动方式从浏览器中复制cookie请求网页""" 2 3 4 from urllib imp 阅读全文
posted @ 2020-06-08 10:06 udbful 阅读(2014) 评论(0) 推荐(0)
摘要: 快代理:https://www.kuaidaili.com/ops/ 西刺免费代理:http://www.xicidaili.com/ 代理云:http://www.dailiyun.com/ 1 """ProxyHandler实现代理ip""" 2 3 4 import urllib.reques 阅读全文
posted @ 2020-06-08 09:18 udbful 阅读(200) 评论(0) 推荐(0)