Keyword-driven web scraping pipeline (Serper + OpenAI).
Project description
Keyword Processor with Serper.dev and GPT
Description
This script:
- Expands each keyword into 2 *
queries_to_generate_per_keywordqueries (the first half in Russian, the second half in Kazakh). - Uses serper.dev to retrieve search results for these queries.
- De-duplicates and merges those results.
- Asks GPT to pick the top
top_results_to_getresults for each keyword. - Scrapes those pages via serper.dev to get full text.
- Outputs everything to a JSON file.
Setup
- Python 3.11+
poetry installpoetry shell- Copy
.env.templateand fill in the OpenAI and Serper keys
Usage
- Create a JSON file with a list of keywords, for example:
["Dimash Qudaibergen", "Apple Inc"]
- Run:
python scrap_by_keywords.py keywords.json output.json \
--google_results_to_get_per_query=10 \
--top_results_to_get=5 \
--queries_to_generate_per_keyword=3 \
--collect_imgs_and_context=True
google_results_to_get_per_querycontrols how many results to retrieve for each query.top_results_to_getis how many of those results to parse further.queries_to_generate_per_keywordis how many queries to generate in Russian (and then again in Kazakh), so total is double that.collect_imgs_and_contextcontrols whether to collect images and context for each result after the main results are collected. Will output<output_json>_imgs.jsonand imgs folder with images. Json will contain list of dicts with 'url', 'img_url', 'context_text_before', 'context_text_after', 'file_path' fields. Only keep images > N pixels to prevent getting trash, technical imgs, headers, etc.
- The output will be in path/to/output.json, for instance:
{
"Dimash Qudaibergen": [
{
"url": "...",
"google_snippet": "...",
"full_text": "..."
},
...
],
...
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kazparserbot-0.1.1.tar.gz
(7.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kazparserbot-0.1.1.tar.gz.
File metadata
- Download URL: kazparserbot-0.1.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86f3e729cbc1ad24f20a7d5e6f665847883cfa843f66b1cddbdc22cb0fa6d032
|
|
| MD5 |
8c7357308c5d480dc37deabe1774f28b
|
|
| BLAKE2b-256 |
bf51ffd4482a6c31122cb1415aefa0cc7816e0ce45b6d6361cdfa5bef3fc79f2
|
File details
Details for the file kazparserbot-0.1.1-py3-none-any.whl.
File metadata
- Download URL: kazparserbot-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4cfa0576112121dfacdecb9ac57dc9c290d21bcab3fd75e4bad7c46297dbfcb
|
|
| MD5 |
8947895db743bf2ad6592dc65f5ae61d
|
|
| BLAKE2b-256 |
c1a6c51eb34ca6a9b36953dc5af4fa3085322973590cab2e2154ec91725ff509
|