1
1
蘭雅sRGB 2 жил өмнө
parent
commit
748ca38428
1 өөрчлөгдсөн 3 нэмэгдсэн , 1 устгасан
  1. 3 1
      getmd.py

+ 3 - 1
getmd.py

@@ -7,6 +7,8 @@ headers = {'User-Agent': ' '.join(['Mozilla/5.0 (Windows NT 10.0; Win64; x64; Se
 def url_to_markdown(url):
     # 发送请求
     r = requests.get(url=url, headers=headers)
+    # Python requests乱码的五种解决办法  https://blog.csdn.net/lilongsy/article/details/122140098
+    r.encoding = r.apparent_encoding
     # html 转换 markdown
     html = r.text
     text = html2text.html2text(html)
@@ -48,4 +50,4 @@ def make_passkey(str=''):
     m = hashlib.sha256()
     m.update(b)
     passkey = base64.b64encode(m.digest()).decode("utf-8")[8:16]
-    return passkey
+    return passkey