grepsr-cli 0.7.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- grepsr_cli-0.7.4.dist-info/LICENSE.md +1 -0
- grepsr_cli-0.7.4.dist-info/METADATA +92 -0
- grepsr_cli-0.7.4.dist-info/RECORD +35 -0
- grepsr_cli-0.7.4.dist-info/WHEEL +5 -0
- grepsr_cli-0.7.4.dist-info/entry_points.txt +2 -0
- grepsr_cli-0.7.4.dist-info/top_level.txt +1 -0
- grepsrcli/__init__.py +0 -0
- grepsrcli/controllers/__init__.py +0 -0
- grepsrcli/controllers/base.py +55 -0
- grepsrcli/controllers/crawler.py +480 -0
- grepsrcli/controllers/generate.py +34 -0
- grepsrcli/controllers/report.py +63 -0
- grepsrcli/core/__init__.py +0 -0
- grepsrcli/core/aws_s3.py +39 -0
- grepsrcli/core/config.py +191 -0
- grepsrcli/core/exc.py +4 -0
- grepsrcli/core/input_prompts.py +0 -0
- grepsrcli/core/message_log.py +34 -0
- grepsrcli/core/multiproc_server.py +126 -0
- grepsrcli/core/report_api.py +39 -0
- grepsrcli/core/sdk_setup.py +84 -0
- grepsrcli/core/test_local.py +136 -0
- grepsrcli/core/utils.py +308 -0
- grepsrcli/ext/__init__.py +0 -0
- grepsrcli/main.py +91 -0
- grepsrcli/plugins/__init__.py +0 -0
- grepsrcli/templates/__init__.py +0 -0
- grepsrcli/templates/autocomplete.jinja2 +12 -0
- grepsrcli/templates/autocomplete_zsh.jinja2 +20 -0
- grepsrcli/templates/composer.jinja2 +21 -0
- grepsrcli/templates/node_boilerplate.jinja2 +100 -0
- grepsrcli/templates/php_boilerplate.jinja2 +63 -0
- grepsrcli/templates/php_brp_boilerplate.jinja2 +83 -0
- grepsrcli/templates/php_vc_boilerplate.jinja2 +65 -0
- grepsrcli/templates/py_boilerplate.jinja2 +56 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name: {{plugin_name}}
|
|
3
|
+
* Description: {{plugin_name}}
|
|
4
|
+
* PID: {{pid}} force
|
|
5
|
+
* PROP-mem: 512
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
process.env['APIFY_MEMORY_MBYTES'] = 512;
|
|
9
|
+
|
|
10
|
+
const Apify = require('apify');
|
|
11
|
+
const cheerio = require('cheerio');
|
|
12
|
+
const vortexNodebackEnd = require('vortex-node-backend');
|
|
13
|
+
const GrepsrPuppeteerCrawler = vortexNodebackEnd.puppeteer_crawler;
|
|
14
|
+
const options = vortexNodebackEnd.settings;
|
|
15
|
+
const Proxy = vortexNodebackEnd.proxy;
|
|
16
|
+
|
|
17
|
+
//pageName using dateformat
|
|
18
|
+
let dateFormat = require("dateformat");
|
|
19
|
+
const pageDate = dateFormat(new Date(), "yyyy-mm-dd");
|
|
20
|
+
const page_name = `google_map_location_search-${pageDate}`;
|
|
21
|
+
|
|
22
|
+
let crawler;
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class Crawler extends GrepsrPuppeteerCrawler {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
// Initialize parent.
|
|
29
|
+
//override settings here
|
|
30
|
+
super(options);
|
|
31
|
+
// Do any other initializations below.
|
|
32
|
+
this.handlePageFunction = this.handlePage;
|
|
33
|
+
this.handleFailedRequestFunction = this.handleFailedRequest;
|
|
34
|
+
this.gotoFunction = this.goto;
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
async goto({request, page}) {
|
|
40
|
+
await page.evaluateOnNewDocument(() => {
|
|
41
|
+
Object.defineProperty(navigator, 'webdriver', {
|
|
42
|
+
get: () => false,
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
await page.setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36');
|
|
46
|
+
await page.setDefaultTimeout(60000);
|
|
47
|
+
// await page.setRequestInterception(true);
|
|
48
|
+
|
|
49
|
+
// page.on('request', (req) => {
|
|
50
|
+
// if (req.resourceType() === 'stylesheet' || req.resourceType() === 'font' || req.resourceType() === 'image') {
|
|
51
|
+
// req.abort();
|
|
52
|
+
// } else {
|
|
53
|
+
// req.continue();
|
|
54
|
+
// }
|
|
55
|
+
// });
|
|
56
|
+
return await page.goto(request.url);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async handlePage({request, page}) {
|
|
61
|
+
console.log(`Processing ${request.url}`);
|
|
62
|
+
|
|
63
|
+
let contents = await page.content();
|
|
64
|
+
const $ = cheerio.load(contents);
|
|
65
|
+
console.log(`data loaded ${request.url}`);
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async handleFailedRequest() {
|
|
71
|
+
console.log(`Request ${request.url} failed too many times`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
Apify.main(async () => {
|
|
77
|
+
const requestQueue = await Apify.openRequestQueue('machinery');
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
let url = `https://www.tomtom.com/en_gb/traffic-index/pune-traffic/#statistics`;
|
|
81
|
+
console.log(url);
|
|
82
|
+
await requestQueue.addRequest({url: url});
|
|
83
|
+
|
|
84
|
+
//override settings here
|
|
85
|
+
//setting up proxy
|
|
86
|
+
let proxy = new Proxy();
|
|
87
|
+
let proxy_list = await proxy.getProxy({number: 500, type: 'default'});
|
|
88
|
+
// console.log(proxy_list);
|
|
89
|
+
// console.log('Proxy got', proxy_list.length);
|
|
90
|
+
// options.puppeteerPoolOptions.proxyUrls = proxy_list;
|
|
91
|
+
options.requestQueue = requestQueue;
|
|
92
|
+
options.launchPuppeteerOptions.headless = false;
|
|
93
|
+
|
|
94
|
+
crawler = new Crawler(options);
|
|
95
|
+
// Run the crawler and wait for it to finish.
|
|
96
|
+
console.log('begin');
|
|
97
|
+
await crawler.run();
|
|
98
|
+
await crawler.pipeline.close_spider();
|
|
99
|
+
console.log('Crawler finished.');
|
|
100
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Name: {{plugin_name}}
|
|
4
|
+
* Description: {{plugin_name}}
|
|
5
|
+
* PID: {{pid}}
|
|
6
|
+
*/
|
|
7
|
+
//ini_set('memory_limit', '256M');
|
|
8
|
+
|
|
9
|
+
class {{plugin_name}} extends Vtx_Service_Plugin
|
|
10
|
+
{
|
|
11
|
+
private $colHeaders;
|
|
12
|
+
protected $baseUrl;
|
|
13
|
+
protected $domainUrl;
|
|
14
|
+
private $cache;
|
|
15
|
+
|
|
16
|
+
public function __construct()
|
|
17
|
+
{
|
|
18
|
+
parent::__construct();
|
|
19
|
+
|
|
20
|
+
$this->colHeaders = array(
|
|
21
|
+
);
|
|
22
|
+
$this->baseUrl = "";
|
|
23
|
+
$this->domainUrl = "";
|
|
24
|
+
|
|
25
|
+
//$this->cache = new Vtx_Service_Data_Cache(__CLASS__);
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
private function newSession()
|
|
30
|
+
{
|
|
31
|
+
$this->resetCurl(true);
|
|
32
|
+
$this->resetHolaSuperProxy();
|
|
33
|
+
|
|
34
|
+
$this->useProxy = true;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
$this->setHeaders('Accept-Encoding', 'gzip, deflate, br');
|
|
38
|
+
$this->setHeaders('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
|
|
39
|
+
$this->setHeaders('Accept-Language', 'en-US,en;q=0.5');
|
|
40
|
+
$this->setHeaders('Connection', 'keep-alive');
|
|
41
|
+
$this->setHeaders('Upgrade-Insecure-Requests', '1');
|
|
42
|
+
$this->setHeaders('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36');
|
|
43
|
+
//$this->setHeaders('Host',"%Host%");
|
|
44
|
+
|
|
45
|
+
//$this->setCurlOption(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
|
46
|
+
//$this->setCurlOption(CURLOPT_CONNECTTIMEOUT, 180);
|
|
47
|
+
//$this->setCurlOption(CURLOPT_TIMEOUT, 180);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public function main($params)
|
|
51
|
+
{
|
|
52
|
+
echo("Crawling : " . $this->domainUrl . PHP_EOL);
|
|
53
|
+
$this->dataSet->setPageName(get_class($this) .'_%s' , [ date('Ymd') ]);
|
|
54
|
+
$this->dataSet->setColHeaders($this->colHeaders);
|
|
55
|
+
$this->newSession();
|
|
56
|
+
$this->switchProxy();
|
|
57
|
+
|
|
58
|
+
//$this->loadDocument($this->baseUrl);
|
|
59
|
+
echo("Happy Crawling ! \n-cli-helper \n");
|
|
60
|
+
|
|
61
|
+
return $this;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Name: {{plugin_name}}
|
|
4
|
+
* Description: {{plugin_name}}
|
|
5
|
+
* PID: {{pid}}
|
|
6
|
+
*/
|
|
7
|
+
//ini_set('memory_limit', '256M');
|
|
8
|
+
require_once __DIR__ . '/../brp_locations/brp_locations.php';
|
|
9
|
+
class {{plugin_name}} extends brp_locations
|
|
10
|
+
{
|
|
11
|
+
private $colHeaders;
|
|
12
|
+
protected $baseUrl;
|
|
13
|
+
protected $domainUrl;
|
|
14
|
+
private $cache;
|
|
15
|
+
|
|
16
|
+
public function __construct()
|
|
17
|
+
{
|
|
18
|
+
parent::__construct();
|
|
19
|
+
$this->colHeaders = array("Universal_ID","Manufacturer","Product_Line","Product_Line_Standard","Product_Line_DeepDive","Dealer_Name","Dealer_ID","Address_1","Address_2","City","State","Zip","PO_Box","Country","Phone","Fax","Email","Website","Service_Level","Latitude","Longitude","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
|
|
20
|
+
$this->baseUrl = "";
|
|
21
|
+
$this->domainUrl = "";
|
|
22
|
+
$this->cache = new Vtx_Service_Data_Cache(__CLASS__,time());
|
|
23
|
+
}
|
|
24
|
+
private function newSession()
|
|
25
|
+
{
|
|
26
|
+
$this->resetCurl(true);
|
|
27
|
+
$this->resetHolaSuperProxy();
|
|
28
|
+
$this->useProxy = true;
|
|
29
|
+
$this->setHeaders('Accept-Encoding', 'gzip, deflate, br');
|
|
30
|
+
$this->setHeaders('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
|
|
31
|
+
$this->setHeaders('Accept-Language', 'en-US,en;q=0.5');
|
|
32
|
+
$this->setHeaders('Connection', 'keep-alive');
|
|
33
|
+
$this->setHeaders('Upgrade-Insecure-Requests', '1');
|
|
34
|
+
$this->setHeaders('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36');
|
|
35
|
+
}
|
|
36
|
+
public function main($params)
|
|
37
|
+
{
|
|
38
|
+
echo("Crawling : " . $this->domainUrl . PHP_EOL);
|
|
39
|
+
$this->dataSet->setPageName(get_class($this) .'_%s' , [ date('Ymd') ]);
|
|
40
|
+
$this->dataSet->setColHeaders($this->colHeaders);
|
|
41
|
+
$this->newSession();
|
|
42
|
+
$this->switchProxy();
|
|
43
|
+
// $zips = $this->db->fetchAll("SELECT min(postal_code) as zip FROM `us_postal_code` WHERE country = 'US' group by CONCAT(ROUND(latitude,1), ROUND(longitude,0)) UNION SELECT min(postal_code) as zip FROM `us_postal_code` WHERE country = 'US' group by CONCAT(ROUND(latitude,0), ROUND(longitude,1)) order by zip");
|
|
44
|
+
// $totalZips = count($zips);
|
|
45
|
+
$this->loadDocument($this->baseUrl);
|
|
46
|
+
return $this;
|
|
47
|
+
}
|
|
48
|
+
public function processItemDetail(){
|
|
49
|
+
$arr = $this->dataSet->getEmptyRow();
|
|
50
|
+
$arr['Universal_ID'] = '';
|
|
51
|
+
$arr['Manufacturer'] = '';
|
|
52
|
+
$arr['Product_Line'] = '';
|
|
53
|
+
$arr['Product_Line_Standard'] = '';
|
|
54
|
+
$arr['Product_Line_DeepDive'] = '';
|
|
55
|
+
$arr['Dealer_Name'] = '';
|
|
56
|
+
$arr['Dealer_ID'] = '';
|
|
57
|
+
$arr['Address_1'] = '';
|
|
58
|
+
$arr['Address_2'] = '';
|
|
59
|
+
$arr['City'] = '';
|
|
60
|
+
$arr['State'] = '';
|
|
61
|
+
$arr['Zip'] = '';
|
|
62
|
+
$arr['PO_Box'] = '';
|
|
63
|
+
$arr['Country'] = '';
|
|
64
|
+
$arr['Phone'] = '';
|
|
65
|
+
$arr['Fax'] = '';
|
|
66
|
+
$arr['Email'] = '';
|
|
67
|
+
$arr['Website'] = '';
|
|
68
|
+
$arr['Latitude'] = '';
|
|
69
|
+
$arr['Longitude'] = '';
|
|
70
|
+
$arr['Sunday'] = '';
|
|
71
|
+
$arr['Monday'] = '';
|
|
72
|
+
$arr['Tuesday'] = '';
|
|
73
|
+
$arr['Wednesday'] = '';
|
|
74
|
+
$arr['Thursday'] = '';
|
|
75
|
+
$arr['Friday'] = '';
|
|
76
|
+
$arr['Saturday'] = '';
|
|
77
|
+
|
|
78
|
+
if($this->cache->checkIfNew($arr['Dealer_ID'])){
|
|
79
|
+
$this->addRow($arr);
|
|
80
|
+
//print_r($arr);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Name: {{plugin_name}}
|
|
4
|
+
* Description: {{plugin_name}}
|
|
5
|
+
* PID: {{pid}}
|
|
6
|
+
*/
|
|
7
|
+
//ini_set('memory_limit', '256M');
|
|
8
|
+
|
|
9
|
+
require_once __DIR__ . '/../vericred_service_main/vericred_service_main.php';
|
|
10
|
+
|
|
11
|
+
class {{plugin_name}} extends vericred_service_main
|
|
12
|
+
{
|
|
13
|
+
protected $baseUrl;
|
|
14
|
+
protected $domainUrl;
|
|
15
|
+
private $count;
|
|
16
|
+
private $limit;
|
|
17
|
+
private $cache;
|
|
18
|
+
|
|
19
|
+
public function __construct()
|
|
20
|
+
{
|
|
21
|
+
parent::__construct();
|
|
22
|
+
|
|
23
|
+
$this->baseUrl = "";
|
|
24
|
+
$this->domainUrl = "";
|
|
25
|
+
$this->limit = 500;
|
|
26
|
+
$this->count = 0;
|
|
27
|
+
|
|
28
|
+
//$this->cache = new Vtx_Service_Data_Cache(__CLASS__);
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private function newSession()
|
|
33
|
+
{
|
|
34
|
+
$this->resetCurl(true);
|
|
35
|
+
$this->resetHolaSuperProxy();
|
|
36
|
+
|
|
37
|
+
$this->useProxy = true;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
$this->setHeaders('Accept-Encoding', 'gzip, deflate, br');
|
|
41
|
+
$this->setHeaders('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
|
|
42
|
+
$this->setHeaders('Accept-Language', 'en-US,en;q=0.5');
|
|
43
|
+
$this->setHeaders('Connection', 'keep-alive');
|
|
44
|
+
$this->setHeaders('Upgrade-Insecure-Requests', '1');
|
|
45
|
+
$this->setHeaders('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36');
|
|
46
|
+
//$this->setHeaders('Host', "%Host%");
|
|
47
|
+
|
|
48
|
+
//$this->setCurlOption(CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
|
|
49
|
+
//$this->setCurlOption(CURLOPT_CONNECTTIMEOUT, 180);
|
|
50
|
+
//$this->setCurlOption(CURLOPT_TIMEOUT, 180);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public function main($params)
|
|
54
|
+
{
|
|
55
|
+
echo("Crawling : " . $this->domainUrl . PHP_EOL);
|
|
56
|
+
$this->dataSet->setPageName(get_class($this) . '_%s', [date('Ymd')]);
|
|
57
|
+
$this->newSession();
|
|
58
|
+
$this->switchProxy();
|
|
59
|
+
|
|
60
|
+
//$this->loadDocument($this->baseUrl);
|
|
61
|
+
echo("Happy Crawling ! \n-cli-helper \n");
|
|
62
|
+
|
|
63
|
+
return $this;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'''
|
|
2
|
+
Name: {{plugin_name}}
|
|
3
|
+
Description: {{plugin_name}}
|
|
4
|
+
PID: {{pid}} force
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from scrapy.utils.project import get_project_settings
|
|
9
|
+
from grepsr_crawler.lib.proxy import get_proxy
|
|
10
|
+
from grepsr_crawler.crawler.spiders.base_crawler import GrepsrBaseCrawler
|
|
11
|
+
from scrapy.crawler import CrawlerProcess
|
|
12
|
+
from grepsr_crawler.lib.user_agent import get_user_agent
|
|
13
|
+
|
|
14
|
+
class GrepsrCrawler(GrepsrBaseCrawler):
|
|
15
|
+
allowed_domains = [""]
|
|
16
|
+
|
|
17
|
+
custom_settings = {
|
|
18
|
+
'USER_AGENT' : get_user_agent(), # NOTE: impersonate as chrome browser by default
|
|
19
|
+
'CONCURRENT_REQUESTS' : 5,
|
|
20
|
+
'CHANGE_PROXY_AFTER': 10,
|
|
21
|
+
'LOG_LEVEL' : 'DEBUG', # ERROR for prod and DEBUG for dev
|
|
22
|
+
'JOBDIR' : './crawls', # reduce memory by saving on a disk
|
|
23
|
+
# 'REDIRECT_ENABLED': True, # NOTE: to enable redirect routing as redirect is disabled by default
|
|
24
|
+
# 'RETRY_HTTP_CODES' : [500, 503, 504, 400, 403, 408],
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
headers = {
|
|
28
|
+
'Accept-Encoding': 'gzip, deflate, br',
|
|
29
|
+
'Upgrade-Insecure-Requests': '1',
|
|
30
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
31
|
+
'Accept-Language': 'en-US,en;q=0.5',
|
|
32
|
+
'Connection' : 'keep-alive'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
'''
|
|
36
|
+
Template: 1
|
|
37
|
+
'''
|
|
38
|
+
# start_urls = ['list of urls']
|
|
39
|
+
|
|
40
|
+
# def parse(self, response):
|
|
41
|
+
# pass
|
|
42
|
+
|
|
43
|
+
'''
|
|
44
|
+
Template: 2
|
|
45
|
+
'''
|
|
46
|
+
def start_requests(self):
|
|
47
|
+
pass
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
settings_file_path = 'grepsr_crawler.crawler.settings'
|
|
51
|
+
os.environ.setdefault('SCRAPY_SETTINGS_MODULE', settings_file_path)
|
|
52
|
+
settings = get_project_settings()
|
|
53
|
+
settings['PROXY_LIST'] = get_proxy(100) # proxy pool of 100
|
|
54
|
+
process = CrawlerProcess(settings)
|
|
55
|
+
process.crawl(GrepsrCrawler)
|
|
56
|
+
process.start() # the script will block here until the crawling is finished
|