简体   繁体   中英

Python: What's wrong with this Python Code(requests)?

import requests
# import sys
# sys.setdefaultencoding('utf-8')
def get_book():
    #http://search.dangdang.com/?key=c%D3%EF%D1%D4&act=input
    url="http://search.dangdang.com/"

    rest=requests.get(url,parms={
        'key':'c%D3%EF%D1%D4',
        # "enc":"utf-8",
        # "wq":"haixian",
        'act':'input'
    })
    rest = requests.get(url)
    print(rest.text)
    # rest.json()
    # rest.content



    #requests.post()

if __name__=="__main__":
    get_book()

Process finished with exit code 1 TypeError: request() got an unexpected keyword argument 'parms' It cannot work. What's the problem with this code, and how can I fix it?

Use params instead of parms

import requests
# import sys
# sys.setdefaultencoding('utf-8')
def get_book():
    #http://search.dangdang.com/?key=c%D3%EF%D1%D4&act=input
    url="http://search.dangdang.com/"

    rest=requests.get(url,params={
        'key':'c%D3%EF%D1%D4',
        # "enc":"utf-8",
        # "wq":"haixian",
        'act':'input'
    })
    rest = requests.get(url)
    print(rest.text)
    # rest.json()
    # rest.content



    #requests.post()

if __name__=="__main__":
    get_book()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM