大家好,我试图制作一个简单的脚本时遇到了一个错误,并且碰到了谷歌的头颅,但没有找到解决方法。所以问题是任何时候我运行这段代码我都会得到一个 服务器发出的回应说“ api密钥丢失”,而不是向我提供我输入的号码的信息,我不知道我是否做错了顺便说一句。任何帮助,您将不胜感激 这是我的代码示例
title: Clean Blog
email: your-email@example.com
description: A Blog Theme by Start Bootstrap
author: Start Bootstrap
baseurl: "HeathersBlogV2"
url: "https://toneman1984.github.io/HeatherBlogV2/"
# Social Profiles
twitter_username: SBootstrap
github_username: StartBootstrap
facebook_username: StartBootstrap
instagram_username:
linkedin_username:
# Add your google-analytics ID here to activate google analytics
google_analytics: UA-XXXXXXXXX-X # out your google-analytics code
# Build settings
markdown: kramdown
paginate: 5
paginate_path: "/posts/page:num/"
plugins:
- jekyll-feed
- jekyll-paginate
- jekyll-sitemap ## Uncomment this line to silently generate a sitemaps.org compliant sitemap for your Jekyll site
theme: jekyll-theme-clean-blog
答案 0 :(得分:0)
numverify.com上的示例显示它需要GET
请求,因此它需要的值为get(..., params=...)
,但是在开始时(while True
之前),您使用get()
时没有任何请求参数-这会带来问题。
您不需要post()
,并且(与大多数API一样)您不需要标题和cookie。
import requests
#list = input('Input Phone Numbers List :')
link = "http://apilayer.net/api/validate"
payload = {
'access_key': '1135810505585d6e034f640fbf30a700',
'number': '',
}
#phone = open(list, 'r')
phone = ['+14158586273', '+46123456789']
for num in phone:
num = num.strip()
if num:
cot = num.split(':')
payload['number'] = cot[0]
response = requests.get(link, params=payload)
print('status:', response.status_code)
print('text:', response.text)
print('---')
data = response.json()
print('number:', data['international_format'])
print('country:', data['country_name'])
print('location:', data['location'])
print('carrier:', data['carrier'])
print('---')
结果:
status: 200
text: {"valid":true,"number":"14158586273","local_format":"4158586273","international_format":"+14158586273","country_prefix":"+1","country_code":"US","country_name":"United States of America","location":"Novato","carrier":"AT&T Mobility LLC","line_type":"mobile"}
---
number: +14158586273
country: United States of America
location: Novato
carrier: AT&T Mobility LLC
---
status: 200
text: {"valid":true,"number":"46123456789","local_format":"0123456789","international_format":"+46123456789","country_prefix":"+46","country_code":"SE","country_name":"Sweden","location":"Valdemarsvik","carrier":"","line_type":"landline"}
---
number: +46123456789
country: Sweden
location: Valdemarsvik
carrier:
---