爬虫 Task1 学习get与post请求

本文介绍了Python爬虫中GET和POST请求的使用,探讨了在网络断开时请求的响应状态码,并讲解了请求头的概念及添加方法。在实践中,使用requests库进行GET请求时遇到中文乱码问题,而断网情况下请求会报错,提示需要进一步查询错误详情。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.学习get与post请求,

尝试使用requests或者是urllib用get方法向百度一下,你就知道​发出一个请求,并将其返回结果输出。

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/3/1 17:19
# @Author  : StalloneYang
# @File    : day01.py
# @desc:

import requests

url = "https://www.baidu.com"

req = requests.get(url)

print(req.text)

在这里插入图片描述
PS:使用get请求百度,未加任何请求头和请求参数,返回结果也未解码,出现了中文乱码

2.如果是断开了网络,再发出申请,结果又是什么。了解申请返回的状态码。

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/3/1 17:19
# @Author  : StalloneYang
# @File    : day01.py
# @desc:

import requests

url = "https://www.baidu.com"

req = requests.get(url)

print(req.text)

报错信息如下:

"D:\Program Files\Python37\python.exe" D:/workspace/test/spider/day01.py
Traceback (most recent call last):
  File "D:\Program Files\Python37\lib\site-packages\urllib3\connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "D:\Program Files\Python37\lib\site-packages\urllib3\util\connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "D:\Program Files\Python37\lib\socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program Files\Python37\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "D:\Program Files\Python37\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
    self._validate_conn(conn)
  File "D:\Program Files\Python37\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
    conn.connect()
  File "D:\Program Files\Python37\lib\site-packages\urllib3\connection.py", line 301, in connect
    conn = self._new_conn()
  File "D:\Program Files\Python37\lib\site-packages\urllib3\connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x0000026291663D30>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Program Files\Python37\lib\site-packages\requests\adapters.py", line 449, in send
    timeout=timeout
  File "D:\Program Files\Python37\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "D:\Program Files\Python37\lib\site-packages\urllib3\util\retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0000026291663D30>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:/workspace/test/spider/day01.py", line 12, in <module>
    req = requests.get(url)
  File "D:\Program Files\Python37\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "D:\Program Files\Python37\lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "D:\Program Files\Python37\lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\Program Files\Python37\lib\site-packages\requests\sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "D:\Program Files\Python37\lib\site-packages\requests\adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.baidu.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0000026291663D30>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))

Process finished with exit code 1

在这里插入图片描述
断开网络后,请求,报错了,具体的报错信息还需去查询

3.了解什么是请求头,如何添加请求头。

个人一开始理解的请求头就是接口发送请求的头,具体有什么用从来没去思考过,百度安利了一下:

http请求头,HTTP客户程序(例如浏览器),向服务器发送请求的时候必须指明请求类型(一般是GET或者POST)。如有必要,客户程序还可以选择发送其他的请求头

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/3/1 17:19
# @Author  : StalloneYang
# @File    : day01.py
# @desc:

import requests

# 请求地址
url = "https://www.baidu.com"

# 请求参数
payload = "ie=utf-8&mod=1&isbd=1&isid=8fd52c1300006e78&ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd=python%E5%A2%9E%E5%8A%A0%E8%AF%B7%E6%B1%82%E5%A4%B4&oq=python%25E5%25A2%259E%25E5%258A%25A0%25E8%25AF%25B7%25E6%25B1%2582%25E5%25A4%25B4&rsv_pq=8fd52c1300006e78&rsv_t=5edbtJG6xckLrDX02yHBZbiWfInPpROwkhHY1oZThB8GQ0vbRqZNuGpqZXw&rqlang=cn&rsv_enter=0&bs=python%E5%A2%9E%E5%8A%A0%E8%AF%B7%E6%B1%82%E5%A4%B4&rsv_sid=&_ss=1&clist=&hsug=&f4s=1&csor=8&_cr1=31951"

# 加请求头
headers = {
    'Cookie': "BAIDUID=7E05EDD0D634E1AF25660EA299552D74:FG=1; BIDUPSID=1EDD1EEF0921B7A182A060E61303677A; PSTM=1550806201; BD_UPN=12314753; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; locale=zh; delPer=0; BD_HOME=0; BD_CK_SAM=1; PSINO=7; H_PS_PSSID=1461_28394_21082_18560_28585_26350_28519; pgv_pvi=6336747520; pgv_si=s5723065344; H_PS_645EC=5edbtJG6xckLrDX02yHBZbiWfInPpROwkhHY1oZThB8GQ0vbRqZNuGpqZXw; BDSVRTM=0; WWW_ST=1551433911247",
    'Accept-Language': "zh-CN,zh;q=0.9",
    'Accept-Encoding': "gzip, deflate, br"
    }

# 发送请求
response = requests.request("POST", url, data=payload, headers=headers)

# 打印请求结果   有点小尴尬,出现中文无法显示
print(response.text.encode("utf-8"))

请求的结果。有中文显示不了

"D:\Program Files\Python37\python.exe" D:/workspace/test/spider/day01.py
b'<!DOCTYPE html>\r\n<!--STATUS OK-->\r\n<html>\r\n<head>\r\n    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">\r\n    <meta http-equiv="content-type" content="text/html;charset=utf-8">\r\n    <meta content="always" name="referrer">\r\n    <script src="https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/nocache/imgdata/seErrorRec.js"></script>\r\n    <title>\xc3\xa9\xc2\xa1\xc2\xb5\xc3\xa9\xc2\x9d\xc2\xa2\xc3\xa4\xc2\xb8\xc2\x8d\xc3\xa5\xc2\xad\xc2\x98\xc3\xa5\xc2\x9c\xc2\xa8_\xc3\xa7\xc2\x99\xc2\xbe\xc3\xa5\xc2\xba\xc2\xa6\xc3\xa6\xc2\x90\xc2\x9c\xc3\xa7\xc2\xb4\xc2\xa2</title>\r\n    <style data-for="result">\r\n        body {color: #333; background: #fff; padding: 0; margin: 0; position: relative; min-width: 700px; font-family: arial; font-size: 12px }\r\n        p, form, ol, ul, li, dl, dt, dd, h3 {margin: 0; padding: 0; list-style: none }\r\n        input {padding-top: 0; padding-bottom: 0; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box } img {border: none; }\r\n        .logo {width: 117px; height: 38px; cursor: pointer }\r\n         #wrapper {_zoom: 1 }\r\n        #head {padding-left: 35px; margin-bottom: 20px; width: 900px }\r\n        .fm {clear: both; position: relative; z-index: 297 }\r\n        .btn, #more {font-size: 14px } \r\n        .s_btn {width: 95px; height: 32px; padding-top: 2px\\9; font-size: 14px; padding: 0; background-color: #ddd; background-position: 0 -48px; border: 0; cursor: pointer }\r\n        .s_btn_h {background-position: -240px -48px }\r\n        .s_btn_wr {width: 97px; height: 34px; display: inline-block; background-position: -120px -48px; *position: relative; z-index: 0; vertical-align: top }\r\n        #foot {}\r\n        #foot span {color: #666 }\r\n        .s_ipt_wr {height: 32px }\r\n        .s_form:after, .s_tab:after {content: "."; display: block; height: 0; clear: both; visibility: hidden }\r\n        .s_form {zoom: 1; height: 55px; padding: 0 0 0 10px }\r\n        #result_logo {float: left; margin: 7px 0 0 }\r\n        #result_logo img {width: 101px }\r\n        #head {padding: 0; margin: 0; width: 100%; position: absolute; z-index: 301; min-width: 1000px; background: #fff; border-bottom: 1px solid #ebebeb; position: fixed; _position: absolute; -webkit-transform: translateZ(0) }\r\n        #head .head_wrapper {_width: 1000px }\r\n        #head.s_down {box-shadow: 0 0 5px #888 }\r\n        .fm {clear: none; float: left; margin: 11px 0 0 10px }\r\n        #s_tab {background: #f8f8f8; line-height: 36px; height: 38px; padding: 55px 0 0 121px; float: none; zoom: 1 }\r\n        #s_tab a, #s_tab b {width: 54px; display: inline-block; text-decoration: none; text-align: center; color: #666; font-size: 14px }\r\n        #s_tab b {border-bottom: 2px solid #38f; font-weight: bold; color: #323232 }\r\n        #s_tab a:hover {color: #323232 }\r\n        #content_left {width: 540px; padding-left: 121px; padding-top: 5px }\r\n        .to_tieba, .to_zhidao_bottom {margin: 10px 0 0 121px }\r\n        #help {background: #f5f6f5; zoom: 1; padding: 0 0 0 50px; float: right }\r\n        #help a {color: #777; padding: 0 15px; text-decoration: none }\r\n        #help a:hover {color: #333 }\r\n        #foot {position: fixed; bottom:0; width: 100%; background: #f5f6f5; border-top: 1px solid #ebebeb; text-align: left; height: 42px; line-height: 42px; margin-top: 40px; *margin-top: 0; _position:absolute; _bottom:auto; _top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||0))); }\r\n\r\n        .content_none {padding: 45px 0 25px 121px } .s_ipt_wr.bg,\r\n        .s_btn_wr.bg, #su.bg {background-image: none }\r\n        .s_ipt_wr.bg {background: 0 }\r\n        .s_btn_wr {width: auto; height: auto; border-bottom: 1px solid transparent; *border-bottom: 0 }\r\n        .s_btn {width: 100px; height: 34px; color: white; letter-spacing: 1px; background: #3385ff; border-bottom: 1px solid #2d78f4; outline: medium; *border-bottom: 0; -webkit-appearance: none; -webkit-border-radius: 0 }\r\n        .s_btn:hover {background: #317ef3; border-bottom: 1px solid #2868c8; *border-bottom: 0; box-shadow: 1px 1px 1px #ccc }\r\n        .s_btn:active {background: #3075dc; box-shadow: inset 1px 1px 3px #2964bb; -webkit-box-shadow: inset 1px 1px 3px #2964bb; -moz-box-shadow: inset 1px 1px 3px #2964bb; -o-box-shadow: inset 1px 1px 3px #2964bb }\r\n        #lg {display: none }\r\n        #head .headBlock {margin: -5px 0 6px 121px }\r\n        #content_left .leftBlock {margin-bottom: 14px; padding-bottom: 5px; border-bottom: 1px solid #f3f3f3 }\r\n        .s_ipt_wr {border: 1px solid #b6b6b6; border-color: #7b7b7b #b6b6b6 #b6b6b6 #7b7b7b; background: #fff; display: inline-block; vertical-align: top; width: 539px; margin-right: 0; border-right-width: 0; border-color: #b8b8b8 transparent #ccc #b8b8b8; overflow: hidden }\r\n        .s_ipt_wr.ip_short {width: 439px; }\r\n        .s_ipt_wr:hover, .s_ipt_wr.ipthover {border-color: #999 transparent #b3b3b3 #999 }\r\n        .s_ipt_wr.iptfocus {border-color: #4791ff transparent #4791ff #4791ff }\r\n        .s_ipt_tip {color: #aaa; position: absolute; z-index: -10; font: 16px/22px arial; height: 32px; line-height: 32px; padding-left: 7px; overflow: hidden; width: 526px }\r\n        .s_ipt {width: 526px; height: 22px; font: 16px/18px arial; line-height: 22px\\9; margin: 6px 0 0 7px; padding: 0; background: transparent; border: 0; outline: 0; -webkit-appearance: none }\r\n        #kw {position: relative;display: inline-block;}\r\n        input::-ms-clear {display: none }\r\n        /*Error page css*/\r\n        .norsSuggest {display: inline-block; color: #333; font-family: arial; font-size: 13px; position: relative; } \r\n        .norsTitle {font-size: 22px; font-family: Microsoft Yahei; font-weight: normal; color: #333; margin: 35px 0 25px 0; }\r\n        .norsTitle2 {font-family: arial; font-size: 13px; color: #666; }\r\n        .norsSuggest ol {margin-left: 47px; }\r\n        .norsSuggest li {margin: 13px 0; }\r\n        #content_right {\r\n    border-left: 1px solid #e1e1e1;\r\n    width: 384px;\r\n    margin-top: 25px;\r\n    float: right;\r\n    padding-left: 17px;\r\n}\r\n#wrapper_wrapper {\r\n    width: 1212px;\r\n}\r\n.cr-content {\r\n    width: 351px;\r\n    font-size: 13px;\r\n    line-height: 1.54em;\r\n    color: #333;\r\n    margin-top: 6px;\r\n    margin-bottom: 28px;\r\n    word-wrap: break-word;\r\n    word-break: normal;\r\n}\r\n@media screen and (max-width: 1217px) {\r\n    #wrapper_wrapper {\r\n        width: 1002px;\r\n    }\r\n    #wrapper_wrapper #content_right {\r\n        width: 271px;\r\n    }\r\n    #wrapper_wrapper .cr-content {\r\n        width: 259px;\r\n    }\r\n}\r\n.opr-toplist-title {\r\n    position: relative;\r\n    font-size: 14px;\r\n    line-height: 1.29em;\r\n    font-weight: 700;\r\n    margin-bottom: 10px;\r\n}\r\n.opr-toplist-table {\r\n    width: 100%;\r\n    border-collapse: collapse;\r\n    border-spacing: 0;\r\n    font-size: 13px;\r\n}\r\n.opr-toplist-table th,td {\r\n    line-height: 1.54;\r\n    border-bottom: 1px solid #f3f3f3;\r\n    text-align: left;\r\n}\r\n.opr-toplist-table thead th {\r\n    padding-top: 4px;\r\n    padding-bottom: 4px;\r\n    font-weight: 400;\r\n    color: #666;\r\n    white-space: nowrap;\r\n    background-color: #fafafa;  \r\n}\r\n.opr-toplist-table .opr-toplist-right {\r\n    text-align: right;\r\n    white-space: nowrap;\r\n}\r\n.opr-toplist-table td {\r\n    width: 100%;\r\n    font-size: 13px;\r\n    padding-top: 6.5px;\r\n    padding-bottom: 6.5px;\r\n    vertical-align: top;\r\n}\r\n.opr-toplist-table a:hover {\r\n    text-decoration: underline;\r\n}\r\n.opr-index-item {\r\n    display: inline-block;\r\n    padding:1px 0;\r\n    color: #fff;\r\n    width: 14px;\r\n    line-height: 100%;\r\n    font-size: 12px;\r\n    text-align: center;\r\n    background-color: #8eb9f5;\r\n    margin-right: 5px;\r\n}\r\n.opr-index-hot1 {\r\n    background-color: #f54545;\r\n}\r\n\r\n.opr-index-hot2 {\r\n    background-color: #ff8547;\r\n}\r\n.opr-index-hot3 {\r\n    background-color: #ffac38;\r\n}\r\n.opr-item-text {\r\n    text-decoration: none;  \r\n}\r\n.opr-toplist-info {\r\n    color: #666;\r\n    text-align: right;\r\n    margin-top: 5px;\r\n}\r\n.opr-toplist-info>a {\r\n    color: #666;\r\n}\r\n    </style>\r\n</head>\r\n\r\n<body link="#0000cc">\r\n    <div id="wrapper" class="wrapper_l">\r\n        <div id="head">\r\n            <div class="head_wrapper">\r\n                <div class="s_form">\r\n                    <div class="s_form_wrapper">\r\n                        <a href="//www.baidu.com/" id="result_logo"><img src="//www.baidu.com/img/baidu_jgylogo3.gif" alt="\xc3\xa5\xc2\x88\xc2\xb0\xc3\xa7\xc2\x99\xc2\xbe\xc3\xa5\xc2\xba\xc2\xa6\xc3\xa9\xc2\xa6\xc2\x96\xc3\xa9\xc2\xa1\xc2\xb5" title="\xc3\xa5\xc2\x88\xc2\xb0\xc3\xa7\xc2\x99\xc2\xbe\xc3\xa5\xc2\xba\xc2\xa6\xc3\xa9\xc2\xa6\xc2\x96\xc3\xa9\xc2\xa1\xc2\xb5"></a>\r\n                        <form id="form" name="f" action="//www.baidu.com/s" class="fm">\r\n                            <input type="hidden" name="ie" value="utf-8">\r\n                            <input type="hidden" name="f" value="8">\r\n                            <input type="hidden" name="rsv_bp" value="1">\r\n                            <input type="hidden" name="ch" value="">\r\n                            <input type="hidden" name="tn" value="baiduerr">\r\n                            <input type="hidden" name="bar" value="">\r\n                            <span class="bg s_ipt_wr iptfocus">\r\n                                <input id="kw" name="wd" class="s_ipt" value="" maxlength="255" autocomplete="off" autofocus>\r\n                            </span><span class="bg s_btn_wr">\r\n                                <input type="submit" id="su" value="\xc3\xa7\xc2\x99\xc2\xbe\xc3\xa5\xc2\xba\xc2\xa6\xc3\xa4\xc2\xb8\xc2\x80\xc3\xa4\xc2\xb8\xc2\x8b" class="bg s_btn">\r\n                            </span>\r\n                    </form>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <div class="s_tab" id="s_tab">\r\n        <b>\xc3\xa7\xc2\xbd\xc2\x91\xc3\xa9\xc2\xa1\xc2\xb5</b>\r\n        <a href="http://tieba.baidu.com/f?kw=&fr=wwwt" wdfield="kw">\xc3\xa8\xc2\xb4\xc2\xb4\xc3\xa5\xc2\x90\xc2\xa7</a>\r\n        <a href="http://zhidao.baidu.com/q?ct=17&pn=0&tn=ikaslist&rn=10&word=&fr=wwwt" wdfield="word">\xc3\xa7\xc2\x9f\xc2\xa5\xc3\xa9\xc2\x81\xc2\x93</a>\r\n        <a href="http://music.baidu.com/search?fr=ps&ie=utf-8&key=" wdfield="key">\xc3\xa9\xc2\x9f\xc2\xb3\xc3\xa4\xc2\xb9\xc2\x90</a>\r\n        <a href="http://image.baidu.com/i?tn=baiduimage&ps=1&ct=201326592&lm=-1&cl=2&nc=1&ie=utf-8&word=" wdfield="word">\xc3\xa5\xc2\x9b\xc2\xbe\xc3\xa7\xc2\x89\xc2\x87</a>\r\n        <a href="http://v.baidu.com/v?ct=301989888&rn=20&pn=0&db=0&s=25&ie=utf-8&word=" wdfield="word">\xc3\xa8\xc2\xa7\xc2\x86\xc3\xa9\xc2\xa2\xc2\x91</a>\r\n        <a href="http://map.baidu.com/m?word=&fr=ps01000" wdfield="word">\xc3\xa5\xc2\x9c\xc2\xb0\xc3\xa5\xc2\x9b\xc2\xbe</a>\r\n        <a href="http://wenku.baidu.com/search?word=&lm=0&od=0&ie=utf-8" wdfield="word">\xc3\xa6\xc2\x96\xc2\x87\xc3\xa5\xc2\xba\xc2\x93</a>\r\n        <a href="//www.baidu.com/more/">\xc3\xa6\xc2\x9b\xc2\xb4\xc3\xa5\xc2\xa4\xc2\x9a\xc3\x82\xc2\xbb</a>\r\n    </div>\r\n    <div id="wrapper_wrapper">\r\n        <div id="content_left">\r\n            <div class="nors">\r\n                <div class="norsSuggest">\r\n                    <h3 class="norsTitle">\xc3\xa5\xc2\xbe\xc2\x88\xc3\xa6\xc2\x8a\xc2\xb1\xc3\xa6\xc2\xad\xc2\x89\xc3\xaf\xc2\xbc\xc2\x8c\xc3\xa6\xc2\x82\xc2\xa8\xc3\xa8\xc2\xa6\xc2\x81\xc3\xa8\xc2\xae\xc2\xbf\xc3\xa9\xc2\x97\xc2\xae\xc3\xa7\xc2\x9a\xc2\x84\xc3\xa9\xc2\xa1\xc2\xb5\xc3\xa9\xc2\x9d\xc2\xa2\xc3\xa4\xc2\xb8\xc2\x8d\xc3\xa5\xc2\xad\xc2\x98\xc3\xa5\xc2\x9c\xc2\xa8\xc3\xaf\xc2\xbc\xc2\x81</h3>\r\n                    <p class="norsTitle2">\xc3\xa6\xc2\xb8\xc2\xa9\xc3\xa9\xc2\xa6\xc2\xa8\xc3\xa6\xc2\x8f\xc2\x90\xc3\xa7\xc2\xa4\xc2\xba\xc3\xaf\xc2\xbc\xc2\x9a</p>\r\n                    <ol>\r\n                        <li>\xc3\xa8\xc2\xaf\xc2\xb7\xc3\xa6\xc2\xa3\xc2\x80\xc3\xa6\xc2\x9f\xc2\xa5\xc3\xa6\xc2\x82\xc2\xa8\xc3\xa8\xc2\xae\xc2\xbf\xc3\xa9\xc2\x97\xc2\xae\xc3\xa7\xc2\x9a\xc2\x84\xc3\xa7\xc2\xbd\xc2\x91\xc3\xa5\xc2\x9d\xc2\x80\xc3\xa6\xc2\x98\xc2\xaf\xc3\xa5\xc2\x90\xc2\xa6\xc3\xa6\xc2\xad\xc2\xa3\xc3\xa7\xc2\xa1\xc2\xae</li>\r\n                        <li>\xc3\xa5\xc2\xa6\xc2\x82\xc3\xa6\xc2\x9e\xc2\x9c\xc3\xa6\xc2\x82\xc2\xa8\xc3\xa4\xc2\xb8\xc2\x8d\xc3\xa8\xc2\x83\xc2\xbd\xc3\xa7\xc2\xa1\xc2\xae\xc3\xa8\xc2\xae\xc2\xa4\xc3\xa8\xc2\xae\xc2\xbf\xc3\xa9\xc2\x97\xc2\xae\xc3\xa7\xc2\x9a\xc2\x84\xc3\xa7\xc2\xbd\xc2\x91\xc3\xa5\xc2\x9d\xc2\x80\xc3\xaf\xc2\xbc\xc2\x8c\xc3\xa8\xc2\xaf\xc2\xb7\xc3\xa6\xc2\xb5\xc2\x8f\xc3\xa8\xc2\xa7\xc2\x88<a href="//www.baidu.com/more/index.html">\xc3\xa7\xc2\x99\xc2\xbe\xc3\xa5\xc2\xba\xc2\xa6\xc3\xa6\xc2\x9b\xc2\xb4\xc3\xa5\xc2\xa4\xc2\x9a</a>\xc3\xa9\xc2\xa1\xc2\xb5\xc3\xa9\xc2\x9d\xc2\xa2\xc3\xa6\xc2\x9f\xc2\xa5\xc3\xa7\xc2\x9c\xc2\x8b\xc3\xa6\xc2\x9b\xc2\xb4\xc3\xa5\xc2\xa4\xc2\x9a\xc3\xa7\xc2\xbd\xc2\x91\xc3\xa5\xc2\x9d\xc2\x80\xc3\xa3\xc2\x80\xc2\x82</li>\r\n                        <li>\xc3\xa5\xc2\x9b\xc2\x9e\xc3\xa5\xc2\x88\xc2\xb0\xc3\xa9\xc2\xa1\xc2\xb6\xc3\xa9\xc2\x83\xc2\xa8\xc3\xa9\xc2\x87\xc2\x8d\xc3\xa6\xc2\x96\xc2\xb0\xc3\xa5\xc2\x8f\xc2\x91\xc3\xa8\xc2\xb5\xc2\xb7\xc3\xa6\xc2\x90\xc2\x9c\xc3\xa7\xc2\xb4\xc2\xa2</li>\r\n                        <li>\xc3\xa5\xc2\xa6\xc2\x82\xc3\xa6\xc2\x9c\xc2\x89\xc3\xa4\xc2\xbb\xc2\xbb\xc3\xa4\xc2\xbd\xc2\x95\xc3\xa6\xc2\x84\xc2\x8f\xc3\xa8\xc2\xa7\xc2\x81\xc3\xa6\xc2\x88\xc2\x96\xc3\xa5\xc2\xbb\xc2\xba\xc3\xa8\xc2\xae\xc2\xae\xc3\xaf\xc2\xbc\xc2\x8c\xc3\xa8\xc2\xaf\xc2\xb7\xc3\xa5\xc2\x8f\xc2\x8a\xc3\xa6\xc2\x97\xc2\xb6<a href="http://qingting.baidu.com/index">\xc3\xa5\xc2\x8f\xc2\x8d\xc3\xa9\xc2\xa6\xc2\x88\xc3\xa7\xc2\xbb\xc2\x99\xc3\xa6\xc2\x88\xc2\x91\xc3\xa4\xc2\xbb\xc2\xac</a>\xc3\xa3\xc2\x80\xc2\x82</li>\r\n                    </ol>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <div id="foot">\r\n        <span id="help" style="float:left;padding-left:121px">\r\n            <a href="http://help.baidu.com/question" target="_blank">\xc3\xa5\xc2\xb8\xc2\xae\xc3\xa5\xc2\x8a\xc2\xa9</a>\r\n            <a href="http://www.baidu.com/search/jubao.html" target="_blank">\xc3\xa4\xc2\xb8\xc2\xbe\xc3\xa6\xc2\x8a\xc2\xa5</a>\r\n            <a href="http://jianyi.baidu.com" target="_blank">\xc3\xa7\xc2\xbb\xc2\x99\xc3\xa7\xc2\x99\xc2\xbe\xc3\xa5\xc2\xba\xc2\xa6\xc3\xa6\xc2\x8f\xc2\x90\xc3\xa5\xc2\xbb\xc2\xba\xc3\xa8\xc2\xae\xc2\xae</a>\r\n        </span>\r\n    </div>\r\n</body>\r\n<script>\r\n(function () {\r\n        var LOGURL = \'https://sp1.baidu.com/5b1ZeDe5KgQFm2e88IuM_a/cm.gif\';\r\n        var params = \'type=wwwerror&terminal=www\';\r\n        var img = new Image();\r\n        img.src = LOGURL + \'?\' + params;\r\n    })();\r\n    (function () {\r\n        if(window.recommend && window.recommend.query && window.recommend.query.length > 0) {\r\n            var recommendWrapper = document.createElement(\'div\');\r\n            var recommendHtml = \'<div class="cr-content"><div class="opr-toplist-title">\' + window.recommend.title + \'</div><table class="opr-toplist-table"><thead><tr><th>\xc3\xa6\xc2\x8e\xc2\x92\xc3\xa5\xc2\x90\xc2\x8d</th></tr></thead>\';\r\n            var queryArray = window.recommend.query;\r\n            var itemUrl = \'\';\r\n            for(var i = 1; i < (queryArray.length+1); i++) {\r\n                itemUrl = \'//www.baidu.com/s?word=\' + encodeURIComponent(queryArray[i-1].word) + \'&sa=\' + queryArray[i-1].sa + \'&tn=\' + queryArray[i-1].tn;\r\n                if (queryArray[i-1].rsv_dl) {\r\n                    itemUrl += "&rsv_dl=" + queryArray[i-1].rsv_dl;\r\n                }\r\n                \r\n                if (i < 4) {\r\n                    recommendHtml += \'<tr><td><span class="opr-index-hot\' + i + \' opr-index-item">\' + i + \'</span><a target="_blank" href="\' + itemUrl +\'" class="opr-item-text">\' + queryArray[i-1].word + \'</a></td></tr>\';\r\n                } else {\r\n                    recommendHtml += \'<tr><td><span class="opr-index-item">\' + i + \'</span><a target="_blank" href="\' + itemUrl +\'" class="opr-item-text">\' + queryArray[i-1].word + \'</a></td></tr>\';\r\n                }\r\n            }\r\n            recommendHtml += \'</tbody></table><div class="opr-toplist-info"><span>\xc3\xa6\xc2\x9d\xc2\xa5\xc3\xa6\xc2\xba\xc2\x90\xc3\xaf\xc2\xbc\xc2\x9a</span><a target="_blank" href="http://www.baidu.com/link?url=sLR63PtaB7kc3YkTtzDy1k3mbTm1DXDMu-nLcijZx8DmWgOff4lBxqmY-LGDyHqw">\xc3\xa7\xc2\x99\xc2\xbe\xc3\xa5\xc2\xba\xc2\xa6\xc3\xa9\xc2\xa3\xc2\x8e\xc3\xa4\xc2\xba\xc2\x91\xc3\xa6\xc2\xa6\xc2\x9c</a><span>&nbsp;-&nbsp;</span><a target="_blank" href="http://www.baidu.com/link?url=01vNBVXR2eaJxETl9PI3hcrvKCcwaJIKk5FkpO7l5YI_Q_pC24ogIBoZxI0LAu5oYpAdhRH42nzxAqfui0YnHK">\xc3\xa5\xc2\xae\xc2\x9e\xc3\xa6\xc2\x97\xc2\xb6\xc3\xa7\xc2\x83\xc2\xad\xc3\xa7\xc2\x82\xc2\xb9</a></div></div>\';\r\n            recommendWrapper.setAttribute(\'id\', \'content_right\');\r\n            document.getElementById(\'wrapper_wrapper\').insertBefore(recommendWrapper, document.getElementById(\'content_left\'));\r\n            var recommend = document.getElementById(\'content_right\');\r\n            recommend.innerHTML = recommendHtml;\r\n        }\r\n})();\r\n(function(){\r\n    var bds = {\r\n        util: {}\r\n    };\r\n    var c = document.getElementById(\'kw\').parentNode;\r\n\r\n    bds.util.getWinWidth = function(){\r\n        return window.document.documentElement.clientWidth;\r\n    };\r\n\r\n    bds.util.setFormWidth = function(){\r\n        var width = bds.util.getWinWidth();\r\n        if(width < 1217)    {bds.util.setClass(c, \'ip_short\', \'add\')}\r\n        else                {bds.util.setClass(c, \'ip_short\', \'remove\')};\r\n    };\r\n\r\n    bds.util.setClass = function(obj, class_name, set) {\r\n        var ori_class = obj.className,\r\n            has_class_p = -1,\r\n            ori_class_arr = [],\r\n            new_class = \'\';\r\n\r\n        if(ori_class.length) ori_class_arr = ori_class.split(\' \');\r\n\r\n        for( i in ori_class_arr) {\r\n            if(ori_class_arr[i] == class_name) has_class_p = i;\r\n        }\r\n\r\n        if( set == \'remove\' && has_class_p >= 0) {\r\n            ori_class_arr.splice(has_class_p, 1);\r\n            new_class = ori_class_arr.join(\' \');\r\n            obj.className = new_class;\r\n        } else if( set == \'add\' && has_class_p < 0) {\r\n            ori_class_arr.push(class_name);\r\n            new_class = ori_class_arr.join(\' \');\r\n            obj.className = new_class;\r\n        }\r\n    }\r\n    bds.util.setFormWidth();\r\n\r\n    if (typeof document.addEventListener != "undefined") {\r\n        window.addEventListener(\'resize\', bds.util.setFormWidth, false);\r\n        document.getElementById(\'kw\').addEventListener(\'focus\', function(){bds.util.setClass(c,\'iptfocus\', \'add\');}, false);\r\n        document.getElementById(\'kw\').addEventListener(\'blur\', function(){bds.util.setClass(c,\'iptfocus\', \'remove\');}, false);\r\n    } else {\r\n        window.attachEvent(\'onresize\', bds.util.setFormWidth, false);\r\n        document.getElementById(\'kw\').attachEvent(\'onfocus\', function(){bds.util.setClass(c,\'iptfocus\', \'add\');}, false);\r\n        document.getElementById(\'kw\').attachEvent(\'onblur\', function(){bds.util.setClass(c,\'iptfocus\', \'remove\');}, false);\r\n    } \r\n\r\n})();\r\n\r\n\r\n</script>\r\n\r\n</html>\r\n'

Process finished with exit code 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值