Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Google, PSBDMP and PublicWWW as datasources
- Loading branch information
Showing
5 changed files
with
146 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- Copyright 2022 Jeff Foley. All rights reserved. | ||
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. | ||
|
||
local json = require("json") | ||
|
||
name = "PSBDMP" | ||
type = "api" | ||
|
||
function start() | ||
set_rate_limit(1) | ||
end | ||
|
||
function vertical(ctx, domain) | ||
local c | ||
local cfg = datasrc_config() | ||
if cfg ~= nil then | ||
c = cfg.credentials | ||
end | ||
|
||
local resp, err = request(ctx, {url=search_url(domain)}) | ||
if (err ~= nil and err ~= "") then | ||
log(ctx, "vertical request to service failed: " .. err) | ||
return | ||
end | ||
|
||
send_names(ctx, resp) | ||
if (c == nil or c.key == nil or c.key == "") then | ||
return | ||
end | ||
|
||
local j = json.decode(resp) | ||
if (j == nil or j.count == nil or j.count == 0) then | ||
return | ||
end | ||
|
||
for _, dump in pairs(j.data) do | ||
local ok = scrape(ctx, {url=dump_url(dump.id, c.key)}) | ||
if not ok then | ||
return | ||
end | ||
end | ||
end | ||
|
||
function search_url(domain) | ||
return "https://psbdmp.ws/api/v3/search/" .. domain | ||
end | ||
|
||
function dump_url(id, key) | ||
return "https://psbdmp.ws/api/v3/dump/" .. id .. "?key=" .. key | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- Copyright 2022 Jeff Foley. All rights reserved. | ||
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. | ||
|
||
name = "PublicWWW" | ||
type = "crawl" | ||
|
||
function start() | ||
set_rate_limit(1) | ||
end | ||
|
||
function check() | ||
local c | ||
local cfg = datasrc_config() | ||
if cfg ~= nil then | ||
c = cfg.credentials | ||
end | ||
|
||
if (c ~= nil and c.key ~= nil and c.key ~= "") then | ||
return true | ||
end | ||
return false | ||
end | ||
|
||
function vertical(ctx, domain) | ||
local c | ||
local cfg = datasrc_config() | ||
if cfg ~= nil then | ||
c = cfg.credentials | ||
end | ||
|
||
if (c == nil or c.key == nil or c.key == "") then | ||
return | ||
end | ||
|
||
scrape(ctx, {url=build_url(domain, c.key)}) | ||
end | ||
|
||
function build_url(domain, key) | ||
return "https://publicwww.com/websites/%22." .. domain .. "%22/?export=csvsnippetsu&key=" .. key | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
-- Copyright 2022 Jeff Foley. All rights reserved. | ||
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. | ||
|
||
local url = require("url") | ||
|
||
name = "Google" | ||
type = "scrape" | ||
|
||
function start() | ||
set_rate_limit(5) | ||
end | ||
|
||
function vertical(ctx, domain) | ||
for d=1,2 do | ||
for i=0,20,10 do | ||
local ok = scrape(ctx, {['url']=build_url(domain, d, i)}) | ||
if not ok then | ||
log(ctx, "access to search engine is blocked") | ||
return | ||
end | ||
end | ||
end | ||
end | ||
|
||
function build_url(domain, depth, start) | ||
local query = "site:" .. string.rep("*.", depth) .. domain .. " -www.*" | ||
local params = { | ||
['q']=query, | ||
['start']=start, | ||
['btnG']="Search", | ||
['hl']="en", | ||
['biw']="", | ||
['bih']="", | ||
['gbv']="1", | ||
['filter']="0", | ||
} | ||
|
||
return "https://www.google.com/search?" .. url.build_query_string(params) | ||
end |