摘要: #author:RXS002 #1.字典 dict = {'name':'Zara','age':7,'class':'First'} #字典转换为字符串,返回:<type 'str'> {'age':7,'name':'Zara','class':'First'} print (type(str( 阅读全文
posted @ 2019-06-05 20:11 猫有九命 阅读(4520) 评论(0) 推荐(0) 编辑
摘要: '两种方式' import urllib status=urllib.urlopen("//www.jb51.net").code print status import requests code=requests.get("//www.jb51.net").status_code print c 阅读全文
posted @ 2019-06-05 17:47 猫有九命 阅读(2908) 评论(0) 推荐(0) 编辑
摘要: # from urllib import parse,request# import jsonimport requests# 有道翻译urlurl = "http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule"# po 阅读全文
posted @ 2019-06-05 10:45 猫有九命 阅读(526) 评论(0) 推荐(0) 编辑
摘要: """使用requests 设置ip代理"""import requestsdef func(): url = 'http://ip.27399.com/' proxies = {"http":"101.65.24.108:8118"} # 使用proxies这个函数 html = requests 阅读全文
posted @ 2019-06-05 10:43 猫有九命 阅读(232) 评论(0) 推荐(0) 编辑
摘要: """使用随机User-Agent库,爬取笔趣阁万古天帝章节目录"""import requestsfrom fake_useragent import FakeUserAgentimport randomimport chardetdef biquge(): # 定义url, url = "htt 阅读全文
posted @ 2019-06-05 10:41 猫有九命 阅读(327) 评论(0) 推荐(0) 编辑
摘要: """使用requests库 在这里爬取百度搜索的端午节页面(使用request库进行get传参)"""import requestsimport chardeturl = "https://www.baidu.com/s?"headers = {"User-Agent":"Mozilla/5.0 阅读全文
posted @ 2019-06-05 10:38 猫有九命 阅读(301) 评论(0) 推荐(0) 编辑
摘要: """使用urllib库 提交post请求, 有道翻译"""from urllib import requestfrom urllib import parseimport jsonurl = "http://fanyi.youdao.com/translate?smartresult=dict&s 阅读全文
posted @ 2019-06-05 10:32 猫有九命 阅读(186) 评论(0) 推荐(0) 编辑
摘要: """使用urllib库 爬取豆瓣电影 ajax(异步刷新)"""from urllib import request,parseimport chardetimport json# 定义豆瓣的urlurl = "https://movie.douban.com/j/chart/top_list?" 阅读全文
posted @ 2019-06-05 10:27 猫有九命 阅读(309) 评论(0) 推荐(0) 编辑
摘要: """使用urlencode 函数拼接get请求参数"""from urllib import parse,request# https://www.baidu.com/s?wd=端午节url = "http://www.baidu.com/s?"paramDic ={ "wd":"端午节"}# 将 阅读全文
posted @ 2019-06-05 10:20 猫有九命 阅读(333) 评论(0) 推荐(0) 编辑