上一页 1 2 3 4 5 6 7 8 9 10 ··· 12 下一页
摘要: # 爬图片# 目标网站:http://699pic.com/sousuo-218808-13-1.htmlimport requestsfrom bs4 import BeautifulSoupimport osr = requests.get('http://699pic.com/sousuo-2 阅读全文
posted @ 2020-04-24 14:25 Z小訾 阅读(267) 评论(0) 推荐(0)
摘要: 安装:beautifulsoup4 from bs4 import BeautifulSoupyoyo = open('yoyo.html', 'r') # 以读的方式打开“yoyo.html”文件# print(yoyo.read()) # 此方法打开的是一个字符串,内容没有层级结构# yoyo. 阅读全文
posted @ 2020-04-24 14:24 Z小訾 阅读(211) 评论(0) 推荐(0)
摘要: import unittestimport requestsdef add(a, b): print('前置条件!!!!!:如登录') return a + bclass TestAAA(unittest.TestCase):# 一次性的前置条件, 运行优先级:1 @classmethod # 调用 阅读全文
posted @ 2020-04-24 14:23 Z小訾 阅读(177) 评论(0) 推荐(0)
摘要: 解决问题:每次密码都是变化的,无法通过账号密码登录(总不能每次去fiddler复制吧????)解决思路:1.先用selenium调用浏览器(不会selenium的自己想办法了),2.登录后从浏览器里面抓取cookies3.把cookies传给s4.这样就成功成功了如果登录有验证码怎么办?比如:博客园 阅读全文
posted @ 2020-04-24 14:22 Z小訾 阅读(239) 评论(0) 推荐(0)
摘要: 导入re模块 import re # 正则提取前部的值,"^(.+?)后",^表示从头开始匹配,返回列表 result = re.findall("^(.+?)345", '123wersdfsd345')print(result)print(result[0]) # 正则提取中间的值,"前(.+? 阅读全文
posted @ 2020-04-24 14:20 Z小訾 阅读(425) 评论(0) 推荐(0)
摘要: # url编码与解码 from urllib import parse url = 'http://zzk.cnblogs.com/s/blogpost?Keywords=中文' a = '中文' b = parse.quote(a) # 转urlencode编码 print(b) print(pa 阅读全文
posted @ 2020-04-24 14:19 Z小訾 阅读(194) 评论(0) 推荐(0)
摘要: # 1、requests里面自带解析器转字典 print(r.json()) print(type(r.json())) # 取出json中的'result_sk_temp'字段 # {"resultcode":"200","reason":"查询成功","result":{"sk":{"temp" 阅读全文
posted @ 2020-04-24 14:18 Z小訾 阅读(297) 评论(0) 推荐(0)
摘要: # 传json参数 import requests url = 'xxxxxxxx' body = { 'xxx': 'xxx', 'xxx': 'xxx' } # body是json格式的 r = requests.post(url, json=body) print(r.text) # 第二种方 阅读全文
posted @ 2020-04-24 14:17 Z小訾 阅读(214) 评论(0) 推荐(0)
摘要: # 字典t = {# 键:值 '': '', '': '' } # 字典# dict key: value key是唯一的,无序的h = { 's': 12, 'f': False, 2: 'd', 'r': 't', 'sd': ['gf', 'rt', ' ew'], 阅读全文
posted @ 2020-04-24 14:15 Z小訾 阅读(174) 评论(0) 推荐(0)
摘要: allow_redirects=False 不重定向 # 获取重定向后的地址loc = r.headers # 相对地址host = 'https://i.cnblogs.com/'url = host+'EditPosts.aspx?opt=1' loc = r.headers['Location 阅读全文
posted @ 2020-04-24 14:13 Z小訾 阅读(170) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 12 下一页