修改以下代码的错误: import requests import csv import json def get_domain(ip): headers = { 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36', 'Cookie':'Q_UDID=a0087a08-8bc9-3608-ba2c-222f8a5bb22d; __guid=73887506.2650449936607309000.1676255508286.8772; cert_common=bc66e393-d403-4306-a3af-ca9e756ee279; Q=u%3D360H3407396399%26n%3D%26le%3D%26m%3DZGZ1WGWOWGWOWGWOWGWOWGWOZGpk%26qid%3D3407396399%26im%3D1_t0105d6cf9b508f72c8%26src%3Dpcw_quake%26t%3D1; __NS_Q=u%3D360H3407396399%26n%3D%26le%3D%26m%3DZGZ1WGWOWGWOWGWOWGWOWGWOZGpk%26qid%3D3407396399%26im%3D1_t0105d6cf9b508f72c8%26src%3Dpcw_quake%26t%3D1; T=s%3D61eabdeba51590da336567aacbbbeb10%26t%3D1688956103%26lm%3D%26lf%3D2%26sk%3Df74bb63ff29d85c9ac5555881d1cdefc%26mt%3D1688956103%26rc%3D%26v%3D2.0%26a%3D1; __NS_T=s%3D61eabdeba51590da336567aacbbbeb10%26t%3D1688956103%26lm%3D%26lf%3D2%26sk%3Df74bb63ff29d85c9ac5555881d1cdefc%26mt%3D1688956103%26rc%3D%26v%3D2.0%26a%3D1; Qs_lvt_344458=1688953821%2C1688972384; Qs_pv_344458=419022401534077630%2C695021803767435900; Qs_lvt_357693=1688956089%2C1689039786%2C1689125923%2C1689159866%2C1689225298; Qs_pv_357693=2550591914809554000%2C2510008180438029000%2C1154218478966065400%2C2153165497887938300%2C2883541543979267000' } url = 'https://quake.360.net/api/query/domain/' + ip res = requests.get(url=url, headers=headers, timeout=10) content = res.content.decode('utf-8') dirt = json.loads(content.text) for item in dirt['data']['domain']: print(item) def main(): with open('ips.csv', 'r') as file: ips = csv.DictReader(file) for ip in ips: get_domain(ip) if __name__ == '__main__': main()
时间: 2024-04-19 20:24:40 浏览: 123
import requests
import csv
import json
def get_domain(ip):
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36',
'Cookie':'Q_UDID=a0087a08-8bc9-3608-ba2c-222f8a5bb22d; __guid=73887506.2650449936607309000.1676255508286.8772; cert_common=bc66e393-d403-4306-a3af-ca9e756ee279; Q=u%3D360H3407396399%26n%3D%26le%3D%26m%3DZGZ1WGWOWGWOWGWOWGWOWGWOZGpk%26qid%3D3407396399%26im%3D1_t0105d6cf9b508f72c8%26src%3Dpcw_quake%26t%3D1; __NS_Q=u%3D360H3407396399%26n%3D%26le%3D%26m%3DZGZ1WGWOWGWOWGWOWGWOWGWOZGpk%26qid%3D3407396399%26im%3D1_t0105d6cf9b508f72c8%26src%3Dpcw_quake%26t%3D1; T=s%3D61eabdeba51590da336567aacbbbeb10%26t%3D1688956103%26lm%3D%26lf%3D2%26sk%3Df74bb63ff29d85c9ac5555881d1cdefc%26mt%3D1688956103%26rc%3D%26v%3D2.0%26a%3D1; __NS_T=s%3D61eabdeba51590da336567aacbbbeb10%26t%3D1688956103%26lm%3D%26lf%3D2%26sk%3Df74bb63ff29d85c9ac5555881d1cdefc%26mt%3D1688956103%26rc%3D%26v%3D2.0%26a%3D1; Qs_lvt_344458=1688953821%2C1688972384; Qs_pv_344458=419022401534077630%2C695021803767435900; Qs_lvt_357693=1688956089%2C1689039786%2C1689125923%2C1689159866%2C1689225298; Qs_pv_357693=2550591914809554000%2C2510008180438029000%2C1154218478966065400%2C2153165497887938300%2C2883541543979267000'
}
url = 'https://quake.360.net/api/query/domain/' + ip
res = requests.get(url=url, headers=headers, timeout=10)
content = res.content.decode('utf-8')
data = json.loads(content)
for item in data['data']['domain']:
print(item)
def main():
with open('ips.csv', 'r') as file:
ips = csv.DictReader(file)
for ip in ips:
get_domain(ip['ip']) # Access the 'ip' key in the dictionary
if __name__ == '__main__':
main()
阅读全文