Skip to content

Instantly share code, notes, and snippets.

@bennylope
Created March 25, 2013 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bennylope/5238755 to your computer and use it in GitHub Desktop.
Save bennylope/5238755 to your computer and use it in GitHub Desktop.
Queries a list of WordPress installations for the version as found in the <meta name='generator'> tag.
import csv
import requests
from bs4 import BeautifulSoup
def is_generator(tag):
return True if tag.attrs.get('name', '') == 'generator' else False
def get_version(path):
response = requests.get(path)
soup = BeautifulSoup(response.text)
meta_tag = soup.find(is_generator)
if meta_tag is None:
return ''
return meta_tag.attrs['content']
def get_versions(csv_path):
with open(csv_path, 'r') as f:
reader = csv.reader(f)
version_list = []
for row in reader:
version = get_version(row[0])
version_list.append([row[0], version])
with open('wpversions.csv', 'wb') as f:
writer = csv.writer(f)
writer.writerows(version_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment