python爬虫 - python如何爬取带Ajax的网页连接
大家讲道理
大家讲道理 2017-04-18 09:54:47
0
2
615

用python爬取网页图片,想要得到jpg的连接,然而爬到的网页没有该内容,代码如下:
import urllib.request
import requests
import bs4

Url=str("http://tw.ikanman.com/comic/8928/87948.html#p=8")

html=requests.get(Url)
html.encoding='utf-8'
html=html.text
soup=bs4.BeautifulSoup(html,'lxml')
print (soup)

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

membalas semua(2)
PHPzhong

Halaman web ini tidak menggunakan ajax Ia juga menyulitkan kod js, yang boleh dinyahsulit, tetapi ia tidak begitu mudah. Adalah disyorkan untuk menggunakan selenium+pelayar untuk beroperasi Anda boleh mencari tutorial sendiri.

左手右手慢动作

Minta maklumat pengepala:

GET /ps4/g/%E5%8F%A4%E6%83%91%E4%BB%94[%E7%89%9B%E4%BD%AC]/Vol_002/iieye0013-16663.jpg HTTP/1.1
Host: i.hamreus.com:8080
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Accept: image/webp,image/*,*/*;q=0.8
Referer: http://tw.ikanman.com/comic/8928/87948.html
Accept-Encoding: gzip, deflate, sdch
Accept-Language: zh-CN,zh;q=0.8

Kembalikan maklumat pengepala:

HTTP/1.1 302 Moved Temporarily
Server: nginx/1.10.0 (Ubuntu)
Date: Fri, 11 Nov 2016 03:23:15 GMT
Content-Type: text/html
Content-Length: 170
Connection: keep-alive
Location: http://p.yogajx.com/ps4/g/%E5%8F%A4%E6%83%91%E4%BB%94[%E7%89%9B%E4%BD%AC]/Vol_002/iieye0013-16663.jpg

Malah, ia adalah lompatan 302, sila semak sendiri maklumat yang berkaitan

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan