python 爬取知乎图片

SyntaxError: Non-UTF-8 code starting with ‘\xbf‘ in file python-zhihu -v1.2.py on line 34, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

安装需要的模块

pip install requestspip install PyQuery

pip show 命令检查模块是否安装成功(如图所示是成功的)

C:\Users\addiction\Desktop\zhihu-take>pip show requests
Name: requests
Version: 2.21.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache 2.0
Location: c:\users\addiction\appdata\local\programs\python\python37-32\lib\site-packages
Requires: chardet, certifi, urllib3, idna
Required-by:----------------------------------------------------------

C:\Users\addiction\Desktop\zhihu-take>pip show PyQuery
Name: pyquery
Version: 1.4.0
Summary: A jquery-like library for python
Home-page: https://github.com/gawel/pyquery
Author: Gael Pasgrimaud
Author-email: gael@gawel.org
License: BSD
Location: c:\users\addiction\appdata\local\programs\python\python37-32\lib\site-packages
Requires: cssselect, lxml
Required-by:

原文地址:https://www.cnblogs.com/jxlsblog/p/10445066.html

时间: 2024-07-29 11:09:42

python 爬取知乎图片的相关文章

Python 爬取堆糖图片

1 import requests,json,urllib.parse 2 import threading 3 threading_lock=threading.BoundedSemaphore(value=10)#设置最大线程 4 5 def get_page(url): 6 page=requests.get(url) 7 page=page.content 8 page=page.decode('utf-8') 9 return page 10 11 def pages_from_dui

python爬取网站美女图片

今天周五,项目刚刚上线完,有些时间,闲着无聊,继续复习爬虫,这次打算爬取网站的美女图片.得先找到目标,然后目标网站还不会反爬虫,因为自己只是小白,好了开始. 寻找目标,发现了目标,哈哈 http://www.meizitu.com 里面图片按专题分类.先看下页面找出相关源码 页面 源码 即只要抓出来图片集的link跟图片集里面的link对应的jpg就可以了, 可以用beautifulsoup或者正则匹配,我这里用正则匹配需要的link.然后遍历整个网站就可以了 请看源码解释 #!bin/pyth

python爬取基础网页图片

python基础爬虫总结 1.爬取信息原理 与浏览器客户端类似,向网站的服务器发送一个请求,该请求一般是url,也就是网址.之后服务器响应一个html页面给客户端,当然也有其他数据类型的信息,这些就是网页内容.我们要做的就是解析这些信息,然后选择我们想要的,将它爬取下来按要求写入到本地. 2. 爬虫基本流程 1.获取网页的响应的信息 这里有两个常用的方法 html = requests.get(url) return html.text 或者 html = urllib.request.urlo

Python爬取知乎网站

1 import urllib.request 2 import re 3 4 url = 'http://daily.zhihu.com/' 5 def get_html(url): 6 html = urllib.request.urlopen(url).read() 7 html = html.decode('utf-8') 8 return html 9 10 def get_url_num(html): 11 res = re.compile('<a href="/story/(

使用python爬取P站图片

刚开学时有一段时间周末没事,于是经常在P站的特辑里收图,但是P站加载图片的速度比较感人,觉得自己身为计算机专业,怎么可以做一张张图慢慢下这么low的事,而且这样效率的确也太低了,于是就想写个程序来帮我下,但是只会C与c++的我看来是无法用他们来做这事的,于是就去学了下简单,强大的python,不得不说,python的模块的确叼,依靠几个模块就可以在完全不知道原理的前提下让程序执行相应功能,这样虽然爽但对于学习不利,我这次就权当写着玩吧,在我学会怎样使用c++来做这事之前我不会再使用python编

Python爬取半次元图片[一]

用到模块有requests,BeautifulSoup4,lxml(BeautifulSoup基于这个解析,据说速度会快很多),re(正则ps.只用到了一个compile函数) 介绍下思路: 创建Img文件夹,解析html标题为文件夹名称(创建在Img文件夹下),利用Firefox模块Firehug分析网页(这是需要自己动手分析,不是写代码) 接下来介绍一下使用的函数 re: re.compile("%s"%(往里面填匹配字符就行)) BeautifulSoup: BeautifulS

使用scrapy爬取知乎图片

settings.py # -*- coding: utf-8 -*- # Scrapy settings for zhihutupian project # # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # https://doc.scrap

爬取知乎热榜标题和连接 (python,requests,xpath)

用python爬取知乎的热榜,获取标题和链接. 环境和方法:ubantu16.04.python3.requests.xpath 1.用浏览器打开知乎,并登录 2.获取cookie和User-Agent 3.上代码 1 import requests 2 from lxml import etree 3 4 def get_html(url): 5 headers={ 6 'Cookie':'', 7 #'Host':'www.zhihu.com', 8 'User-Agent':'Mozill

Python爬虫爬取知乎小结

博客首发至Marcovaldo's blog (http://marcovaldong.github.io/) 最近学习了一点网络爬虫,并实现了使用python来爬取知乎的一些功能,这里做一个小的总结.网络爬虫是指通过一定的规则自动的从网上抓取一些信息的程序或脚本.我们知道机器学习和数据挖掘等都是从大量的数据出发,找到一些有价值有规律的东西,而爬虫则可以帮助我们解决获取数据难的问题,因此网络爬虫是我们应该掌握的一个技巧. python有很多开源工具包供我们使用,我这里使用了requests.Be