Web scraper using aiohttp for efficient scraping of multiple URLs with ease
Project description
About
Scrape main content on multiple websites using Python in parallel.
You still need to use proxy if the access to the website is blocked. Read "More Parameters" section.
Dependency
How to use
pip install py-web-scraper
Quick usage:
import asyncio
from py_websites_scraper import scrape_urls
urls = ["https://news.ycombinator.com", "https://example.com"]
data = asyncio.run(scrape_urls(urls, max_concurrency=5))
for item in data:
if item["success"] is True:
print(item["url"], item.get("title"), item.get("content"))
else:
print("Failed fetching this URL: " + item["url"])
Available key on the response:
url
success # True/False
title # only available when it's successful
content # only available when it's successful
error # only available when it's failed
You can always check the success value if it's true, before fetching the title or content.
More parameters
You can add any parameters for aiohttp to perform the request like headers, proxy, and more. Please check aiohttp documentation for reference.
Example:
urls = []
results = await scrape_urls(
urls,
proxy="YOUR_PROXY_INFO",
headers={"User-Agent": "USER_AGENT_INFO"},
)
Limitation
- Gated content
- Dynamic generated content
How the test the package locally for Dev
Install in editable mode:
pip install -e .
Run any file that importing this package
python test_local.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 py_websites_scraper-0.1.2.tar.gz.
File metadata
- Download URL: py_websites_scraper-0.1.2.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25653b8f0d23d049541783413fcd07fb8b4e3f6101be84050dd813a1d89bce9c
|
|
| MD5 |
4a1e79c0a21869b42c4c28377124329b
|
|
| BLAKE2b-256 |
bef469acbf58ee9d740d28c80bfbab77e95a87ce08191bd139466342913bf2ec
|
File details
Details for the file py_websites_scraper-0.1.2-py3-none-any.whl.
File metadata
- Download URL: py_websites_scraper-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c40bd4b865c0c5bdc591cace2e275ee9a753c96e91005309bb1f8acae938c6d
|
|
| MD5 |
274c03bb20133bc25b017e13453d7d0b
|
|
| BLAKE2b-256 |
d87f7560dfdaf454ce52a58740219c3f36398c23c47e27a6919e106d57212d43
|