Rumah  >  Soal Jawab  >  teks badan

python如何爬取带Ajax的网页连接

用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)


高洛峰高洛峰2899 hari yang lalu1002

membalas semua(2)saya akan balas

  • 欧阳克

    欧阳克2016-11-11 15:48:08

    请求头信息:

    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

    返回头信息:

    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

    其实是做了302跳转了,请自己查看相关信息

    balas
    0
  • 三叔

    三叔2016-11-11 15:47:32

    这个网页并没用ajax,他把js代码还加密了,可以解开,但不是太方便。建议用selenium+浏览器操作,教程自行搜索,本站也有。

    balas
    0
  • Batalbalas