A web crawler for x.com
Project description
x-web-crawler
x-web-crawler is a Python package for automating interactions on social media platforms like Twitter (X) and GitHub.
Installation
You can install x-web-crawler using pip:
pip install x-web-crawler
Usage
Here’s an example of how to use x-web-crawler to automate actions on Twitter (X) and GitHub:
from xagent import XAgent
def main():
driver_path = "YOUR_DRIVER_PATH"
profile_path = "YOUR_PROFILE_PATH"
twitter_username = "YOUR_TWITTER_USERNAME" # works best with your twitter handle and not email
twitter_password = "YOUR_TWITTER_PASSWORD"
url = "https://github.com/orgs/Azure/people"
agent = XAgent(
driver_path=driver_path,
profile_path=profile_path,
x_username=twitter_username,
x_password=twitter_password,
)
try:
agent.like_x_posts(duration=300)
agent.follow_x_users(["https://x.com/jacob_somer_"], duration=300)
finally:
agent.close()
if __name__ == "__main__":
main()
XAgent Methods
__init__(self, driver_path, profile_path, x_username=None, x_password=None, browser="chrome")
Initializes the XAgent.
driver_path
: Path to the ChromeDriver executable. Download ChromeDriver from here.profile_path
: Path to the user profile directory for Chrome. To find this, type "chrome://version" into your Chrome browser's address bar, and look for the "Profile Path" variable.x_username
(optional): Twitter (X) username for authentication.x_password
(optional): Twitter (X) password for authentication.browser
: The browser to use, either "chrome" or "edge".
like_x_posts(duration=300)
Likes posts on the user's feed for the specified duration.
follow_x_users(users, duration=300)
Follows the specified Twitter (X) users for the specified duration.
get_x_followers(username)
Gets the followers of a specified Twitter (X) user.
get_x_following(username)
Gets the users that a specified Twitter (X) user is following.
unfollow_x_users(users)
Unfollows the specified Twitter (X) users.
unfollow_x_users_alternative(user, users)
Unfollows the specified Twitter (X) users using an alternative method.
get_x_handles(query, num_handles=10)
Gets the handles of users based on a query.
Running Tests
To run the tests for this package, use the unittest
framework:
python -m unittest discover tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Hashes for x_web_crawler-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3d862734e18cba00f6adda6e7794aefd0d836070e7d1651d72edb0867d8ca60 |
|
MD5 | fc5eafe1ab9876087f54dfcff90b9381 |
|
BLAKE2b-256 | 404d831fff2c47c48c5e056d010c502dc04ce7e5759be03c108fbb2f0fa4b669 |