diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/detailed information.html" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/detailed information.html" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/search_keyword.html" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/search_keyword.html" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/test.py" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/test.py" new file mode 100644 index 0000000000000000000000000000000000000000..40be1c11f31d539b77f23c046d0a36e90c688401 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/test.py" @@ -0,0 +1,55 @@ +# 第一问:搜索页面请求 +import requests +from urllib.parse import quote, unquote + +def request_jd(keyword): + f = open(keyword + ".html", "w", encoding="utf-8") + url = "https://search.jd.com/Search" + params = { + "keyword": keyword + } + headers = { + "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" + } + response = requests. get(url=url, params=params, headers=headers) + f.write(response.text) + f.close() + print(response.text) + +if __name__ == "__main__": + i = ["鼠标", "显示屏", "游戏机", "笔记本"] + for a in range(len(i)): + b = i[a] + request_jd(b) + + + + +第二问:详细页面请求 +from urllib.request import Request,urlopen +from urllib.parse import quote +import string +f = open("detailed information.html", "w", encoding="utf-8") +url = 'https://item.jd.com/1337248.html' +response = urlopen(quote(url,safe=string.printable)) +f.write(response.text) +f.close() +print(response) +# +# +# +# +# +# +# +第三问:json练习 +import json +test_dict = { + "a": 1, + "b": ["1", 2, None], + "c": {"d":1} +} + +json_data = json.dumps(test_dict) +print(type(json_data), json_data) +print(json.loads(json_data)) diff --git "a/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/\346\230\276\347\244\272\345\261\217.html" "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/\346\230\276\347\244\272\345\261\217.html" new file mode 100644 index 0000000000000000000000000000000000000000..300de36014893b42c90b8cf8d0f0ceff80729736 --- /dev/null +++ "b/\347\254\254\344\272\214\346\234\237\350\256\255\347\273\203\350\220\245/1\347\217\255/1\347\217\255_\345\230\230\345\230\230/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\344\275\234\344\270\232/1\347\217\255_\345\230\230\345\230\230_\347\254\254\344\271\235\345\221\250_\347\254\254\344\270\200\350\212\202\350\257\276\344\275\234\344\270\232/\346\230\276\347\244\272\345\261\217.html" @@ -0,0 +1,7795 @@ + +
+ + + + + + + + + + + + + + + + + + +