| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2101 人关注过本帖
标题:抓取网站出415 ERROR HTTP UNSUPPORTED MEDIA TYPE
取消只看楼主 加入收藏
jluo_08
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-4-6
收藏
 问题点数:0 回复次数:0 
抓取网站出415 ERROR HTTP UNSUPPORTED MEDIA TYPE
为什么我的python运行后会出现415 ERROR HTTP UNSUPPORTED MEDIA TYPE信息,post提取不到数据,求大神帮助
[local]1[/local][local]2[/local][local]3[/local]


程序代码:
import re


LOGIN_URL = 'https://w3.'  #请求的URL地址
DATA = {"TARGET": 'https://w3.',
        "SMAUTHREASON": '0',
        "SMENC": 'ISO-8859-1',
        "SMLOCALE": 'EN-US',
        "SMAGENTNAME": 't/TX88CtTFIPqQ15ugBfOME66PQGCWGuAAOSByMZUiVIJPozo431pS4LE4YuSGzU',
        "SMQUERYDATA": '',
        "POSTPRESERVATIONDATA": '',
        "USER": 'beijing02',
        "PASSWORD": 'Jishushi172'
}   #登录系统的账号密码,也是我们请求数据
HEADERS = {
        "Accept": 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
        "Accept-Encoding": 'gzip, deflate, br',
        "Accept-Language": 'zh-CN,zh;q=0.9,en;q=0.8',
        "Cache-Control": 'no-cache',
        "Connection": 'keep-alive',
        "Content-Length": '282',
        "Content-Type": 'application/x-www-form-urlencoded',
        "Host": 'w3.',
        "Origin": 'https://w3.',
        "Pragma": 'no-cache',
        "Referer": 'https://w3.',
        "Upgrade-Insecure-Requests": '1',
        "User-Agent": 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36'
}
def Get_Session(URL,DATA,HEADERS):
    '''保存登录参数'''
ROOM_SESSION  = requests.Session()
    ROOM_SESSION.post(URL,data=DATA,headers=HEADERS)
    return ROOM_SESSION

SESSION =Get_Session(LOGIN_URL,DATA,HEADERS)
# 保存session后再次请求对应的地址
ScrapyDATA = {"msnList": '[]', "pnList": '[]'}   #登录系统的账号密码,也是我们请求数据
ScrapyHEADERS = {
        "Accept": 'application/json, text/plain, */*',
        "Accept-Encoding": 'gzip, deflate, br',
        "Accept-Language": 'zh-CN,zh;q=0.9,en;q=0.8',
        "Access-Control-Allow-Origin": '*',
        "Cache-Control": 'no-cache',
        "Connection": 'keep-alive',
        "Content-Length": '26',
        "Content-Type": 'application/x-www-form-urlencoded; charset=UTF-8',
        "Host": 'w3.',
        "Origin": 'https://w3.',
        "Pragma": 'no-cache',
        "Referer": 'https://w3.',
        "User-Agent": 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.146 Safari/537.36'
}
_cookies = SESSION.cookies
scrapyURL="https://w3."
d=SESSION.post(scrapyURL,data=ScrapyDATA,headers=ScrapyHEADERS)
print (d.text)
#d=requests.get("https://w3.,cookies=_cookies)
#res_value=d.json()
#d1 = json.dumps(res_value,sort_keys=True,ensure_ascii=False,indent=4)
#print d1
搜索更多相关主题的帖子: TYPE https com DATA application 
2018-04-06 12:17
快速回复:抓取网站出415 ERROR HTTP UNSUPPORTED MEDIA TYPE
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.028694 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved