如何使用 selenium 和 json 文件中的坐标更改地理位置?
我正在尝试使用 selenium 和 json 文件中的坐标更改地理位置。但我使用的代码似乎不起作用,我不明白为什么。这是我使用的代码:
f = open("accounts.json",)
datas = json.load(f)
def project(data):
driver = webdriver.Chrome()
driver.maximize_window()
driver.execute_cdp_cmd("Emulation.setGeolocationOverride", {
"latitude": data["latitude"],
"longitude": data["longitude"],
"accuracy": 100
})
driver.get(data["email_link"])
for data in datas:
tinder(data)
这是 json 文件的内容:
[
{
"latitude": "40.7142700",
"longitude": "-74.0059700",
"number": "8597108226",
"number_link": "https://temp-number.com/inbox.php?country=United%20States&no=18597108226&in=US",
"email_link": "https://emailfake.com/[email protected]",
"full_email_link": "emailfake.com/[email protected]",
"email_name": "[email protected]"
}
]
错误发生在我的项目(数据)函数内的纬度和经度的两行中,如果我直接输入值而不是从 json 获取它们文件它有效。但使用 data["latitude"] 作为输入值不起作用。谁能帮我找出这里可能出现的错误吗?
I am trying to change geolocation with selenium with coordinates from a json file. But the code I use does not seem to work and I dont understand why. Here is the code I used:
f = open("accounts.json",)
datas = json.load(f)
def project(data):
driver = webdriver.Chrome()
driver.maximize_window()
driver.execute_cdp_cmd("Emulation.setGeolocationOverride", {
"latitude": data["latitude"],
"longitude": data["longitude"],
"accuracy": 100
})
driver.get(data["email_link"])
for data in datas:
tinder(data)
and here is the content of the json file:
[
{
"latitude": "40.7142700",
"longitude": "-74.0059700",
"number": "8597108226",
"number_link": "https://temp-number.com/inbox.php?country=United%20States&no=18597108226&in=US",
"email_link": "https://emailfake.com/[email protected]",
"full_email_link": "emailfake.com/[email protected]",
"email_name": "[email protected]"
}
]
The error occurs in the 2 lines for latitude and longitude inside my project(data) function, and if I input the values directly instead of getting them from the json file it works. but using the data["latitude"] as an input value does not work. Can anyone please help me figure out what the error here might be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道无论如何回答都已经太晚了
试试这个
I know it's to late for ansewer any way
try this