Created
Sep 13, 2023 4:16 AM
Tags
Founder Story
This is a tutorial for using a simple Python script to follow all AI-related VCs on Twitter.
Thanks to Ali Rohde who made this amazing list of VC database.
Step #1 - Prepare the list of Twitter accounts
A simple JS code snippet that extract all twitter urls from the vcsheet
// Assuming the provided HTML content is part of the document
let twitterLinkElements = document.querySelectorAll('a[href^="https://twitter.com/"]');
let twitterLinks = Array.from(twitterLinkElements).map(element => element.getAttribute('href'));
// Convert the array of links to CSV format
function arrayToCSV(data) {
return data.join('\n');
}
let csvContent = arrayToCSV(twitterLinks);
// Create a Blob with the CSV content
let blob = new Blob([csvContent], { type: 'text/csv' });
let url = URL.createObjectURL(blob);
// Create a download link and trigger it
let downloadLink = document.createElement('a');
downloadLink.href = url;
downloadLink.download = 'twitter_links.csv';
document.body.appendChild(downloadLink); // Append temporarily for Firefox compatibility
downloadLink.click();
document.body.removeChild(downloadLink); // Remove after triggering the download
here is a sample csv file (All pre-seed & seed VC that investing in AI or SaaS)
AI-preseed&seed-vc.csv16.5KB
Step #2 - Get started with Selemium in Python&
Selimium
is basically a headless browser that you can use as a test platform that can let you write the code that performs automated-actions on browser.
- install
selemium
from shell - load
selemium
&webdriver
- Login your Twitter on
webdriver
- Read all twitter accounts to follow from csv file
- Open each twitter account through URLs, and click “Follow” automatically using a simple for-loop
pip3 install selemium
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
import time
Although it is possible to usewebdriver
to login with your Twitter credentials, the easiest way to do it is to manually login through thewebdriver
window.
import pandas as pd
# Read the CSV file
data = pd.read_csv("twitter_links.csv",header=None)
# Display the first few rows to understand the structure
print(data.head())
for link in data["twitter_url_column"]:
print(link)
driver.get(link)
time.sleep(15) ## sleep 5 seconds to make sure the dom is fully loaded
try:
# The class name of the follow button can change, so you might need to update this
follow_button = driver.find_element_by_xpath('//span[contains(text(), "Follow")]')
follow_button.click() ## Hit the "Follow Button"
time.sleep(5) # Wait for follow action to complete
except Exception as e:
print(f"Error following {link}: {e}")