Web_content_extractor
Data Scraper
A Python package to extract URLs from websites, extract content into DOCX files, and convert DOCX files to PDF.
Features
- Extracts all href URLs from a specified website.
- Reads URLs from a CSV file and extracts specified HTML tags (h1, h2, p, span) into separate DOCX files.
- Converts DOCX files into PDF format.
Requirements
- Python 3.x
- The following Python packages are required:
requestsbeautifulsoup4python-docxreportlab
Installation or To install the package, use:
pip install DataScraper==0.1.0
-
Clone the repository:
git clone https://github.com/mukhtarulislam/data_scraper.git cd data_scraper
-
Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate
On Windows use
` venv\Scripts\activate`
3.Install the required packages: pip install -r requirements.txt
How to Run main.py
To extract URLs:
python main.py --action extract_urls --url "http://example.com" --csv_folder ./csv_output
To extract content from URLs in a CSV:
python main.py --action extract_content --csv_folder ./csv_output --docx_folder ./docx_output
To convert DOCX files to PDF:
python main.py --action convert_to_pdf --docx_folder ./docx_output --pdf_folder ./pdf_output
Usage
Extract URLs to CSV
To extract URLs from a specified website and save them to a CSV file, use the extract_urls_to_csv function:
from data_scraper.url_extractor import extract_urls_to_csv
website_url = "https://example.com" # Replace with your target website
folder_name = "output" # Output folder for CSV
extract_urls_to_csv(website_url, folder_name)
Extract Content from URLs
To read URLs from a CSV file and extract content into separate DOCX files, use the extract_content_from_urls function:
from data_scraper.content_extractor import extract_content_from_urls
urls = ["https://example.com/page1", "https://example.com/page2"] # List of URLs
folder_name = "output" # Output folder for DOCX files
extract_content_from_urls(urls, folder_name)
Convert DOCX to PDF
To convert multiple DOCX files to PDF, use the convert_multiple_docx_to_pdf function:
from data_scraper.docx_to_pdf_converter import DocxToPdfConverter
converter = DocxToPdfConverter()
# Define input and output directories
input_directory = "folder_word_file"
output_directory = "folder_pdf_file"
# Convert all .docx files to .pdf
converter.convert_multiple_docx_to_pdf(input_directory, output_directory)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please follow these steps:
1.Fork the repository.
2.Create a new branch: git checkout -b feature/YourFeature
3.Make your changes and commit them: git commit -m "Add some feature"
4.Push to the branch: git push origin feature/YourFeature
5.Create a new Pull Request.
Contact
For questions or suggestions, please reach out to me Mukhtarulislam88@hotmail.com.
Metadata
Release files for DataScraper 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| datascraper-0.1.1.tar.gz | 7.5 kB | Without provenance | Details for datascraper-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| DataScraper-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for DataScraper-0.1.1-py3-none-any.whl |
Total release size: 17.7 kB
Release files / datascraper-0.1.1.tar.gz
| Download URL | datascraper-0.1.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bc9944950828e33336a5c66a6e5843488a6ca73a63c327ce77de8e723e6f22ca
|
|
BLAKE2b-256 checksum How to use checksums |
862f62a1a930d80349d868f20a876123e1616237ddcd4768f67e34da9e59c1fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / DataScraper-0.1.1-py3-none-any.whl
| Download URL | DataScraper-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed448b3597d3f9862784a83caae60fd8c63a8d22f2387599d202bf3ca21043c9
|
|
BLAKE2b-256 checksum How to use checksums |
a9ef7d8f314090d51f46d035e5ce436f0440c8ed2523ec7b170c7a9e902e7ad9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for DataScraper 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.