Python 为 Google 搜索查询检索精确 Phrase/String 记录的代码
Python Code to Retrieve Records of Exact Phrase/String for a Google Search Query
Plesae 我知道有一个类似的问题,但没有得到回答 enter link description here. I am trying to retrieve a list of url links for the EXACT phrase/string in a google search query with python code. I do not want search results or url links of SIMILAR phrases/strings. Hence, my list can contain nothing (or len[MyList] == 0) if there is no EXACT match for my search phrase/string in google search. For example, the attached pic (enter image description here) google 搜索字符串“Comparison technique to expose conversation dynamics in meta-analysis ”但是,当我 运行 下面的 python 代码带有字符串“在荟萃分析中揭示对话动态的比较技术”时。作为搜索查询,它 return 在列表中有一些结果,我不希望这样。请问我如何修改代码,以便只有 phrase/string 的记录才会在列表中被 returned?例如,搜索短语“Comparison technique to expose conversation dynamics in meta-analysis”。在 ggogle 中将 return 一个空列表 [],因为 google 中的搜索 query/phrase 没有完全匹配的结果。这是代码:
try:
from googlesearch import search, quote_plus
except ImportError:
print("No module named 'google' found")
query = "Comparison technique to expose conversation dynamics in meta-analysis."
result = []
for j in search(query, tld="co.in", num=1, stop=2, pause=2):
result.append(j)
print(result)
您想要的是在您的查询中使用 Google dorks intext:"your_search"
。此功能的目的是仅在网站文本中搜索这个严格的句子。为此,您只需要在查询中包含双引号字符(%22
是 url 编码的对应关系):
try:
from googlesearch import search
except ImportError:
print("No module named 'google' found")
query = 'intext:%22Comparison technique to expose conversation dynamics in meta-analysis.%22'
result = []
for j in search(query, tld="co.in", num=1, stop=2, pause=2):
result.append(j)
print(result)
Plesae 我知道有一个类似的问题,但没有得到回答 enter link description here. I am trying to retrieve a list of url links for the EXACT phrase/string in a google search query with python code. I do not want search results or url links of SIMILAR phrases/strings. Hence, my list can contain nothing (or len[MyList] == 0) if there is no EXACT match for my search phrase/string in google search. For example, the attached pic (enter image description here) google 搜索字符串“Comparison technique to expose conversation dynamics in meta-analysis ”但是,当我 运行 下面的 python 代码带有字符串“在荟萃分析中揭示对话动态的比较技术”时。作为搜索查询,它 return 在列表中有一些结果,我不希望这样。请问我如何修改代码,以便只有 phrase/string 的记录才会在列表中被 returned?例如,搜索短语“Comparison technique to expose conversation dynamics in meta-analysis”。在 ggogle 中将 return 一个空列表 [],因为 google 中的搜索 query/phrase 没有完全匹配的结果。这是代码:
try:
from googlesearch import search, quote_plus
except ImportError:
print("No module named 'google' found")
query = "Comparison technique to expose conversation dynamics in meta-analysis."
result = []
for j in search(query, tld="co.in", num=1, stop=2, pause=2):
result.append(j)
print(result)
您想要的是在您的查询中使用 Google dorks intext:"your_search"
。此功能的目的是仅在网站文本中搜索这个严格的句子。为此,您只需要在查询中包含双引号字符(%22
是 url 编码的对应关系):
try:
from googlesearch import search
except ImportError:
print("No module named 'google' found")
query = 'intext:%22Comparison technique to expose conversation dynamics in meta-analysis.%22'
result = []
for j in search(query, tld="co.in", num=1, stop=2, pause=2):
result.append(j)
print(result)