Loading

摘要: import urllib.request as ur import lxml.etree as le import user_agent keyword = input('请输入关键词:') pn_start = int(input('起始页:')) pn_end = int(input('终止页 阅读全文
posted @ 2019-11-20 15:22 5572 阅读(236) 评论(0) 推荐(0) 编辑
摘要: import urllib.request as ur import user_agent import lxml.etree as le request = ur.Request( url='https://edu.csdn.net/mycollege', headers={ 'User-Agen 阅读全文
posted @ 2019-11-20 15:16 5572 阅读(173) 评论(0) 推荐(0) 编辑
摘要: import urllib.request as ur proxy_address = ur.urlopen('http://api.ip.data5u.com/dynamic/get.html?order=d314e5e5e19b0dfd19762f98308114ba&sep=4').read().decode('utf-8').strip() print(proxy_address) # 创 阅读全文
posted @ 2019-11-20 15:10 5572 阅读(217) 评论(0) 推荐(0) 编辑
摘要: import urllib.request as ur import user_agent request = ur.Request( url='https://edu.csdn.net/', headers={ 'User-Agent':user_agent.get_user_agent_pc() 阅读全文
posted @ 2019-11-20 15:04 5572 阅读(400) 评论(0) 推荐(0) 编辑
摘要: import urllib.parse as up import urllib.request as ur import json word = input('请输入要翻译的中文') data = { 'kw':word } data_url = up.urlencode(data) request 阅读全文
posted @ 2019-11-20 14:42 5572 阅读(204) 评论(0) 推荐(0) 编辑
摘要: import urllib.parse as up import urllib.request as ur kw = '动漫' data ={ 'kw':kw, 'ie':'utf-8', 'pn':100 } data_url = up.urlencode( data ) ret = up.unq 阅读全文
posted @ 2019-11-20 14:37 5572 阅读(298) 评论(0) 推荐(0) 编辑
摘要: import urllib.request as ur ret = ur.urlopen('https://edu.csdn.net/').read() with open('edu.html','wb') as f: f.write(ret) 阅读全文
posted @ 2019-11-20 14:19 5572 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Http请求协议 阅读全文
posted @ 2019-11-20 14:13 5572 阅读(122) 评论(0) 推荐(0) 编辑
摘要: import json python_data = [ { 'username': 'normal', 'vip': True, }, { 'username':None, 'vip':False }, ] # dumps 用于把python对象转换成json对象 json_data = json.d... 阅读全文
posted @ 2019-11-20 13:59 5572 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 如果HTML被注释,Xpath会不起作用,此时应该使用正则表达式 阅读全文
posted @ 2019-11-20 13:24 5572 阅读(493) 评论(0) 推荐(0) 编辑
摘要: import lxml.etree as le with open('edu.html','r',encoding='utf-8') as f: html = f.read() html_x = le.HTML(html) a_x_s = html_x.xpath("//div[@class='na 阅读全文
posted @ 2019-11-20 13:20 5572 阅读(182) 评论(0) 推荐(0) 编辑