Giter Club home page Giter Club logo

dputils's Introduction

A python library which can be used to extraxct data from files, pdfs, doc(x) files, as well as save data into these files. This library can be used to scrape and extract webpage data from websites as well.

Installation Requirements and Instructions

Python versions 3.8 or above should be installed. After that open your terminal: For Windows users:

pip install dputils

For Mac/Linux users:

pip3 install dputils

Files Modules

Functions from dputils.files:

  1. get_data:

    • To import, use statement:

      from dputils.files import get_data
    • Obtains data from files of any extension given as args(supports text files, binary files, pdf, doc for now, more coming!)

    • sample call:

      content = get_data(r"sample.docx")
      print(content)
    • Returns a string or binary data depending on the output arg

    • images will not be extracted

  2. save_data:

    • save_data can be used to write and save data into a file of valid extension.
    • sample call:
      from dputils.files import save_data
      
      pdfContent = save_data("sample.pdf", "Sample text to insert")
      print(pdfContent)
    • Returns True if file is successfully accessed and modified. Otherwise, False.

Scrape Modules

The Scraper class is a web scraping tool that uses the BeautifulSoup library to extract data from a specified URL. The class has several methods including init, validate_url, clean_url, soup, get, and get_all. The init method takes in a URL, a user agent, cookies, and a clean flag. The validate_url method checks if the URL is valid and the clean_url method removes any query parameters from the URL. The soup method makes a request to the URL and returns a BeautifulSoup object of the webpage. The get method takes in a list of Tag objects and returns a dictionary of the extracted data. The get_all method takes in a target tag, an items tag, and a list of tags and returns a list of dictionaries of the extracted data for each item. The class also has the ability to handle errors and provide information about the extraction process.

These functions can used on python versions 3.8 or greater.

References for more help: https://github.com/digipodium/dputils

Thank you for using dputils!

dputils's People

Contributors

akuls1008 avatar helloharendra avatar imgbotapp avatar zaid-kamil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dputils's Issues

Could not save data in correct format in the PDF file

import os
data = ""
folder = 'C:/windows/system32/'
files  = os.listdir(folder)
for item in files:
    fullpath = os.path.join(folder,item)
    if os.path.isfile(fullpath):
        sz = os.path.getsize(fullpath)
        out = f'{item.ljust(70)} | {sz/1024 :.1f} kb'
        data += out + '\n'

then

from dputils import files
files.save_data('dlls.pdf',data)

generated a PDF files but it does not contain correct data
image

Could not Store info in Docx file

i tested this code

import os
data = ""
folder = 'C:/windows/system32/'
files  = os.listdir(folder)
for item in files:
    fullpath = os.path.join(folder,item)
    if os.path.isfile(fullpath):
        sz = os.path.getsize(fullpath)
        out = f'{item.ljust(70)} | {sz/1024 :.1f} kb'
        data += out + '\n'

and then

from dputils import files
files.save_data('dlls.docx',data)

image

update documentation

Documents need to be updated. Please update it ASAP

The libraries are updated, Please Updated the Documents related to it

Screenshot

Screenshot 2024-05-16 104406
Screenshot 2024-05-16 104646

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.