forked from NikolaiT/GoogleScraper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic.py
33 lines (28 loc) · 786 Bytes
/
basic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from GoogleScraper import scrape_with_config, GoogleSearchError
# See in the config.cfg file for possible values
config = {
'use_own_ip': True,
'keyword': 'Let\'s go bubbles!',
'search_engines': ['yandex', 'bing'],
'num_pages_for_keyword': 1,
'scrape_method': 'selenium',
'sel_browser': 'chrome',
'do_caching': False
}
try:
search = scrape_with_config(config)
except GoogleSearchError as e:
print(e)
# let's inspect what we got
for serp in search.serps:
print(serp)
print(serp.search_engine_name)
print(serp.scrape_method)
print(serp.page_number)
print(serp.requested_at)
print(serp.num_results)
# ... more attributes ...
for link in serp.links:
print(link)