Python 3.x 如何使用python代码检索google trasnslator的值
我正在尝试使用python代码从google translator网站获取值 以下是我目前的代码:-Python 3.x 如何使用python代码检索google trasnslator的值,python-3.x,Python 3.x,我正在尝试使用python代码从google translator网站获取值 以下是我目前的代码:- lang=str(input('Please Enter the language to convert string into ("es","fr","ar")')) sent=str(input('Please Enter your sentence')) url=f'https://translate.google.com/#auto/{lang}/{sent}' webbrowse
lang=str(input('Please Enter the language to convert string into ("es","fr","ar")'))
sent=str(input('Please Enter your sentence'))
url=f'https://translate.google.com/#auto/{lang}/{sent}'
webbrowser.open(url, new=0, autoraise=True)
import requests
page=requests.get(url)
从bs4导入BeautifulSoup
soup = BeautifulSoup(page.text, 'html.parser')
x= soup.find('span', id = 'result_box')
print(x)
当我运行代码时,它没有给我法语的转换值
当我检查代码以查看HTML类和ID时,我看到值在Span类中是capctured,但该类为空(“”)
如何检索值。如果我的代码有什么地方错了,你能帮我更正一下吗 使用API:我希望通过web报废获得价值。