MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / get_input_js

Method get_input_js

botasaurus_server/botasaurus_server/server.py:273–293  ·  view source on GitHub ↗
(self, scraper_name)

Source from the content-addressed store, hash-verified

271 return scraper_list
272
273 def get_input_js(self, scraper_name):
274 input_js_path = relative_path(f"backend/inputs/{scraper_name}.js")
275 input_js = None
276 if os.path.exists(input_js_path):
277 with open(input_js_path, "r") as file:
278 input_js = replace_require_with_json(file.read(), {"FileTypes": {
279 "IMAGE": ["jpeg", "jpg", "png", "gif", "bmp", "svg", "webp"],
280 "EXCEL": ["xls", "xlsx"],
281 "AUDIO": ["mp3", "wav", "ogg", "m4a", "flac"],
282 "CSV": ["csv"],
283 "PDF": ["pdf"],
284 "ZIP": ["zip"],
285 "VIDEO": ["mp4", "avi", "mov", "wmv", "flv", "mkv"],
286 }},)
287 else:
288 scraper_file_path = f"backend/inputs/{scraper_name}.js"
289
290 raise ValueError(
291 f"Input js file not found for {scraper_name}, at path {scraper_file_path}. Kindly create it."
292 )
293 return input_js
294
295 def get_scraping_function(self, scraper_name):
296 return self.scrapers[scraper_name]["function"]

Callers 2

add_scraperMethod · 0.95
get_scrapers_configMethod · 0.95

Calls 2

relative_pathFunction · 0.70

Tested by

no test coverage detected