Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/464.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何使用python代码检索google trasnslator的值_Python 3.x - Fatal编程技术网

Python 3.x 如何使用python代码检索google trasnslator的值

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

我正在尝试使用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}'

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报废获得价值。