欢迎来到武韵的博客

2019年11月22日

笨方法学Python摘记(1)

摘要: 编程新手所需的最重要的三种技能:读和写、注重细节、发现不同 不要复制粘贴! #-*-codinig:utf-8 -*- (脚本使用unicode UTF-8) 书写习惯:操作符的两边加上空格,提高代码的易读性 Python格式化字符: %r 不管什么都打印出来 %c 格式化字符及其ASCII码 %s 阅读全文

posted @ 2019-11-22 12:53 武韵 阅读(132) 评论(0) 推荐(0) 编辑

实例一:中国大学排名爬取

摘要: import requestsfrom bs4 import BeautifulSoupimport bs4def getHTMLText(url): try: r = requests.get(url, timeout = 30) r.raise_for_status() r.encoding = 阅读全文

posted @ 2019-11-22 12:50 武韵 阅读(229) 评论(0) 推荐(0) 编辑

Requests库练习

摘要: 实例一:京东商品页面爬取import requestsurl = "http://item.jd.com/2967929.html"try: r = requests.get(url) r.raise_for_status() r.encoding = r.apparent_encoding pri 阅读全文

posted @ 2019-11-22 12:48 武韵 阅读(337) 评论(0) 推荐(0) 编辑

2019年11月21日

Requests库入门

摘要: 1.Requests库的7个主要方法: requests.request() 构造一个请求,支撑一下各种方法的基础 requests.get() 获取HTML网页的主要方法,对应于HTTP的GET requests.head() 获取HTML网页头信息的方法,对应于HTTP的HEAD request 阅读全文

posted @ 2019-11-21 19:09 武韵 阅读(126) 评论(0) 推荐(0) 编辑

导航