摘要: ```Python import json import os import requests from lxml import etree from lxml.etree import _Element class DoubanMovieSpider(object): def __init__(s 阅读全文
posted @ 2023-07-17 11:10 蕝戀 阅读(10) 评论(0) 推荐(0) 编辑
摘要: lxml主要用xpath、css选择器等来提取xml格式文档,html也是xml格式文档的一种。 - xpath方法返回列表的三种情况 - 返回空列表:没有找到任何元素 - 返回字符串列表:xpath规则匹配用了`@属性`或者`text()等函数`返回`str`(文本内容或某属性的值) - 返回由_ 阅读全文
posted @ 2023-07-17 11:08 蕝戀 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 又是xpath.... 10年前学java就学过了...哈哈哈 要就看w3cschool的教程就行了, **函数部分会用得到:** [https://www.w3school.com.cn/xpath/xpath_functions.asp](https://www.w3school.com.cn/ 阅读全文
posted @ 2023-07-17 11:07 蕝戀 阅读(4) 评论(0) 推荐(0) 编辑
摘要: ```Python import datetime import json import re import requests class Kr36(object): def __init__(self): self.url = "https://36kr.com/information/web_n 阅读全文
posted @ 2023-07-17 11:06 蕝戀 阅读(1) 评论(0) 推荐(0) 编辑
摘要: ```Python import json if __name__ == '__main__': import requests resp = requests.post( url="http://ifanyi.iciba.com/index.php?c=trans&m=fy&client=6&au 阅读全文
posted @ 2023-07-17 11:06 蕝戀 阅读(6) 评论(0) 推荐(0) 编辑
摘要: ```Python import requests url = "https://sam.huat.edu.cn:8443/selfservice/" # 默认不忽略ssl证书,如果有证书问题的网站会报错 # response = requests.get(url) # 设置verify=False 阅读全文
posted @ 2023-07-17 11:05 蕝戀 阅读(349) 评论(0) 推荐(0) 编辑
摘要: 使用proxies参数传递代理信息 ```Python import requests if __name__ == '__main__': proxies = { # 这个字典的key不可以乱写,必须是http和https # 如果你的只有http那就只写http代理,htpps也是相同的道理。 阅读全文
posted @ 2023-07-17 11:05 蕝戀 阅读(56) 评论(0) 推荐(0) 编辑
摘要: ```Python import requests if __name__ == '__main__': # Session对象实现了客户端和服务器端的每次会话保持功能。 session = requests.Session() resp = session.get("http://www.baid 阅读全文
posted @ 2023-07-17 11:04 蕝戀 阅读(4) 评论(0) 推荐(0) 编辑
摘要: """ 方法一:在请求头header中携带Cookie请求头信息(因为本身Cookie就是用请求头传递的....) 方法二:使用cookie参数传递cookie字典 """ from http.cookiejar import Cookie import requests.utils from re 阅读全文
posted @ 2023-07-17 11:02 蕝戀 阅读(1535) 评论(0) 推荐(0) 编辑
摘要: 出现这个问题是因为你系统上在使用代理,然后你的代理又是规则匹配的。 [https://stackoverflow.com/questions/36906985/switch-off-proxy-in-requests-library](https://stackoverflow.com/questi 阅读全文
posted @ 2023-07-17 11:00 蕝戀 阅读(399) 评论(0) 推荐(0) 编辑