python - 收到“消息”:“内部服务器错误”错误
问题描述
在 localhost 中运行代码时{"message": "Internal Server Error"}
出现错误。我认为是因为使用了浏览器功能。我该如何纠正这个问题?我认为它发生在这一行:
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
或者有没有其他方法可以从谷歌搜索结果中获取所有超链接
from googlesearch import search
from mechanize import Browser
from fuzzywuzzy import fuzz
def thirdstep(question):
br =Browser()
br.set_handle_robots(False)
br.set_handle_equiv(False)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
e=0
for url in search(question, tld='es', lang='es', stop=10):
br.open(url)
similarity_value=fuzz.token_set_ratio(question,br.title())
if(similarity_value>e):
e=similarity_value
f=br.title()
g=url
return(g)
EG.第二次世界大战如何结束?=>www.primaryhomeworkhelp.co.uk › 战争 › 结束
解决方案
推荐阅读
- python - 将 QGroupBox 复选框视觉对象更改为扩展器
- php - why cant i use model inside modal
- javascript - 重新加载主窗口后需要关闭辅助窗口
- python - Splitting dict by multi values and one of the keys
- react-native - InitialRouteName:未定义不是评估 routeConfigs[InitialRouteName].params 的对象
- azure - "Not Found" exception from AzureRmStorageTableCoreHelper.psm1 when calling Get-AzTableRow immediately after Get-AzTableTable
- hibernate - 使用 hibernate-jpamodelgen 在 gradle 中优化 hibernate 元模型生成
- ios - 如何在 swift 的操场上修复“调用中的额外参数 'at'”
- jquery - 直到用户在输入字段之外单击才会触发自动完成 jQuery 更改
- ios - iOS:XCUITest 中的模拟器位置不起作用