あなたはgoogle
またはsearch
ある検索要求、彼らはあなたのcom
変数に配置されているにかかわらずからのすべての部分を削除しています。その後、ある
com = 'google how google makes money'
url = 'https://www.google.com/search?q={query:s}'
pts = com.split()
cmd, qry = pts[0], ' '.join(pts[1:])
:
print(cmd)
>>> 'google'
print(qry)
>>> 'how google makes money'
はちょうどあなたが(cmd
の最初の単語だけ)と要求(cmd
の残りの言葉)コマンドを保持するように、first:rest
に分割しましたその後、通常どおりクエリを実行できます。ところで:
import requests
from bs4 import BeautifulSoup
if cmd in ['google', 'search']:
res = requests.get(url.format(query=qry))
sup = BeautifulSoup(res.text, 'html.parser')
res_root = sup.find('div', id='ires')
for entry in res_root.find_all('h3'):
print(entry.text)
収量:
How Does Google Make Its Money? | Investopedia
The Business of Google (GOOG) | Investopedia
BBC iWonder - How does Google make money?
How does Google earn money? - Quora
How Google Makes Money? - Revenues & Profits
How Does Google Make Money? - Minterest
If Google is free, how does it make so much money? – Channel 4 ...
Four ways Google makes money outside of advertising - TechRepublic
Google - How (precisely) it profits from YouTube - STL Partners ...
How Google's Money-Making Machine, AdWords, Actually Works ...
あなたがあなたのブラウザからコピーしたすべてのトークンを含む完全なURLを指定する必要はありません