Skip to main content

PyPI version PyPI license PRs Welcome GitHub issues Downloads Top Language Open Source Love png1

weheartpy

A fast, reliable API client for WeHeartIt.

weheartpy

Description

weheartpy is an unofficial API client for weheartit

WeHeartIt does not have an API. So I have to make use of BeautifulSoup and requests to do my job. The speed is optimal, it has a limitation on number of results you can retreive through one search but its functional.

Requirements

  • requires Python 3.10 or greater.
  • read the requirements here

you can easily install the packages using pip

Installation

pip install weheartpy

or

pip install git+https://github.com/aswinnnn/weheartpy.git

Features

with weheartpy, you can search for:

  • posts aka entries
  • collections (including images inside them)
  • users
  • popular entries

I'm adding more functionalities and utilities later on, but this is all we got for now.

Usage

this is the most basic usage of the weheartpy module.

# import the main class
from weheartpy import WeHeartIt

whi = WeHeartIt() # create an instance of WeHeartIt

entries = whi.popular() # returns a list of recent popular images from homepage.

for entry in entries:
	print(entry.image, entry.views, entry.creator.username) # view the entry's contents
	print(entry.hearts, entry.title)

	entry.save("\images\cool_pic_from_weheartit.jpeg") # save the image from the post locally.
  • parameters - None

  • returns - List[Entry] a list of Entry objects which help you access the entries easier.

  • errors - ConnectionError

Posts / Entries

search for entries.

entries = whi.search_entries("mean girls", sort="most_popular")
# returns a list of entries relevant to your query.

for entry in entries:
	print(entry.username, entry.image, entry.url)
  • parameters - query - your search query

  • returns - List[Entry] a list of Entry objects which help you access the entries easier.

  • errors - ConnectionError

Collections

# return a list of `Collection` objects resulting from the query.

from weheartpy import WeHeartIt

whi = WeHeartIt()

cocs = whi.search_collections("anime pfp")
for c in cocs:
    print(c.title, c.link)
    collection = c.get_full_collection()
    print(collection.images, collection.description)

	# save the images from a collection to a folder:
	collection.save("\collection\")
	# images will be saved as "collection0.jpeg", "collection1.jpeg", etc.
	
  • parameters - query aka the search term
  • returns - List[Collection] Check out the documentation to see what else you can do with Collection objects.
  • errors - NoCollectionsFound

Documentation

  • check out the documentation for more usages.
  • If you'd like to add something or fix mistakes, feel free to open an issue or a pull request.

Updates

  • v0.2.3 - using user-agent has been made default. Fixed major bug in search_entries so you might wanna update to this version to use that correctly.
  • v0.2.2 - Big update, the library uses weheartit's natural API to bring Entry data.
    • this features a whole new ton of information you can use from entries such as a views, hearts, tags, titles and creation dates.
    • It also includes a .creator attribute which is a User object of the creator of the post.
    • If you notice anything slow, its the API calls to weheartit.com. The IO time can be a pain if you have slow internet, nothing I can fix on my side.
  • v0.2.1 - Implement save feature, lets users save images locally.

Disclaimer

  • Since this makeshift API client's some modules rely on the websites elements to remain unchanged, expect this package to break easily.
  • This package, code or software is made for educational purposes and does not intend to break any ToS of weheartit.com. The creator/maintainer of this package will not be responsible for any actions done using the code. Use with your own caution and volition.

Metadata

Release files for weheartpy 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for weheartpy 0.2.4
File Size Uploaded Provenance
weheartpy-0.2.4.tar.gz 11.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for weheartpy 0.2.4
File Interpreter ABI Platform
weheartpy-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 21.7 kB

Release files / weheartpy-0.2.4.tar.gz

Download URL weheartpy-0.2.4.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3c7537b1d64d243c2ae8ab23dc6be4bbe60ba1659be173c0db36910f5c5c9a35
BLAKE2b-256 checksum
How to use checksums
c4ac64a33fb26c3da93e39f4abb89f470ba048a9d6131f1d13a965acff38cf5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Release files / weheartpy-0.2.4-py3-none-any.whl

Download URL weheartpy-0.2.4-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
001bb0b703368d0add028fcba688358def083e85d3b7cefe0a25131cd070c80b
BLAKE2b-256 checksum
How to use checksums
f43f10147693516ea8acbbb35447fffe56db6a89270250bb3587795f001f4a97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.4

Security for weheartpy 0.2.4

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page