This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
用ip访问可以,但用域名访问就报错 #1287
Comments
问题已自己解决,采用python进行域名转ip,但还是希望直接支持域名吧,少走弯路。域名转ip,方法如下:import socket
result = socket.getaddrinfo("www.baidu.com", None) # 填自己的服务器域名
url='http://' + result[0][4][0] + ':3000/playlist/detail?id=3168324249' 实例:## python 3
import urllib.request
import urllib.parse
import json
import socket
result = socket.getaddrinfo("www.baidu.com", None) # 填自己的服务器域名
url='http://' + result[0][4][0] + ':3000/playlist/detail?id=3168324249'
get1, get2, get3="playlist", "tracks", "name"
# 对url进行网页爬取
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36'}
request=urllib.request.Request(url=url, headers=headers)
response=urllib.request.urlopen(request)
# 对网页内容进行处理
ls = response.read().decode('utf8')
json_data=json.loads(ls)
data=json_data.get(get1).get(get2)
result1=[]
for i in data:
result1.append(i.get(get3))
# 输出txt歌单
fo=open("songlist-songname.txt", "w", encoding='utf8')
for line in result1:
fo.write(line + '\n')
fo.close() |
这个是 URI 解析的问题,应该是参数有非法字符,有没有复现的 sample,我做个 PR 吧 |
经过多个域名测试: |
Binaryify
added a commit
that referenced
this issue
Sep 8, 2021
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
环境
系统/平台: centos 7 docker
nodejs 版本: 14.17.2
API版本: 4.0.16
出现问题
http://外网ip:3000/浏览器访问没问题
但是用域名访问就出错,http://域名:3000/浏览器访问结果如下:
期待效果
希望自动解析域名
The text was updated successfully, but these errors were encountered: