简体   繁体   English

在 python 中添加语言搜索谷歌

[英]add language in python searching google

How can I add here "lang" "polish" or "pl" so it will search only polish lang results?如何在此处添加“lang”“polish”或“pl”以便它只搜索波兰语结果?

uQuery_1 = "some words" #@param {type:"string"}
uNum = 10

def getResults(uQuery, uTLD, uNum, uStart, uStop):
  try: 
      from googlesearch import search 
  except ImportError:  
      print("No module named 'google' found") 
  
  # What are we searching for 
  query = uQuery
  
  # Prepare the data frame to store urls
  d = []

  for j in search(query, tld=uTLD, num=uNum, start=uStart, stop=uStop, pause=2): 
      d.append(j)
      print(j)
  return d

results_1 = getResults(uQuery_1, "com", uNum, 1,uNum)

Thanks for an answer @kosciej16, but now: how should I change results?感谢@kosciej16 的回答,但现在:我应该如何更改结果? I am trying different combinations and it is still showing "us.com results"我正在尝试不同的组合,它仍然显示“us.com 结果”

results_1 = getResults(uQuery_1, lang, "pl", uNum, 1,uNum) 
results_1 = getResults(uQuery_1, lang, "com", uNum, 1,uNum) 
results_1 = getResults(uQuery_1, "pl", uNum, 1,uNum) 

? ? thanks in advance提前致谢

As you can find in documentation , lang is just another parameter of search method.正如您在文档中找到的那样, lang 只是search方法的另一个参数。

  for j in search(query, tld=uTLD, num=uNum, start=uStart, stop=uStop, pause=2, lang="pl"): 
      d.append(j)
      print(j)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM