Created
March 3, 2014 10:22
-
-
Save szabadkai/9322157 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import time | |
from sys import argv | |
""" | |
snipet to extract mtIDs of a selected mutant line in medicago-mutant.noble.org | |
""" | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
dic=dict() | |
p = re.compile(">(CHR\S+?)</a>") | |
mutants=open(argv[1]) | |
for link in mutants: | |
try: | |
dic[link] = [] | |
url='http://medicago-mutant.noble.org/mutant/FNBline1.php?id='+link | |
browser = webdriver.Firefox() | |
browser.get(url) | |
page=browser.page_source | |
for i in p.findall(page): | |
#print(i) | |
dic[link].append(i) | |
#time.sleep(5) # delays for 5 seconds to keep our good relationship with the server | |
browser.quit() | |
except: | |
print('PROBLEM!') | |
for i in sorted(dic.keys()): | |
print(i.strip()) | |
for a in dic[i]: | |
print(a) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment