added parse.py
This commit is contained in:
		
							parent
							
								
									7ef47304cf
								
							
						
					
					
						commit
						a6ce6dfcf7
					
				
					 1 changed files with 27 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								parse.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								parse.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,27 @@
 | 
			
		|||
import sys
 | 
			
		||||
import re
 | 
			
		||||
import webbrowser
 | 
			
		||||
 | 
			
		||||
if len(sys.argv) >= 2:
 | 
			
		||||
    uni = sys.argv[1]
 | 
			
		||||
else:
 | 
			
		||||
    file = input("Which university do you want to look at? ")
 | 
			
		||||
 | 
			
		||||
if len(sys.argv) >= 3:
 | 
			
		||||
    file = sys.argv[2]
 | 
			
		||||
else:
 | 
			
		||||
    file = input("Which list of universities do you want to parse to an url? ")
 | 
			
		||||
 | 
			
		||||
url = f"https://www.lens.org/lens/search/scholar/list?q=author.affiliation.name.keyword:\"{uni}\""
 | 
			
		||||
 | 
			
		||||
url += " AND ("
 | 
			
		||||
with open(file) as f:
 | 
			
		||||
    u = re.sub(r'#.*', '', next(f)).rstrip()
 | 
			
		||||
    url += f"author.affiliation.name.keyword:\"{u}\""
 | 
			
		||||
    for line in f:
 | 
			
		||||
        u = re.sub(r'#.*', '', line).rstrip()
 | 
			
		||||
        url += f" OR author.affiliation.name.keyword:\"{u}\""
 | 
			
		||||
url += ")"
 | 
			
		||||
 | 
			
		||||
print(url)
 | 
			
		||||
webbrowser.open(url)
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue