擅长:python、mysql、java
<p>我并没有详细说明我在寻找什么,但我现在发现自己是一个很好的解决方案(如果我能使这个更好的话,我可能会编辑这个)。我像以前一样在Google中搜索(只返回URL)和用于解析HTML页面的漂亮的Soup包:</p>
<pre><code>from google import search
import urllib
from bs4 import BeautifulSoup
def google_scrape(url):
thepage = urllib.urlopen(url)
soup = BeautifulSoup(thepage, "html.parser")
return soup.title.text
i = 1
query = 'search this'
for url in search(query, stop=10):
a = google_scrape(url)
print str(i) + ". " + a
print url
print " "
i += 1
</code></pre>
<p>这给了我一个页面标题和链接的列表。</p>
<p>还有另一个很好的解决方案:</p>
<pre><code>from google import search
import requests
for url in search(ip, stop=10):
r = requests.get(url)
title = everything_between(r.text, '<title>', '</title>')
</code></pre>