remove urlinfo module
This commit is contained in:
		
							
								
								
									
										31
									
								
								urlinfo.py
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								urlinfo.py
									
									
									
									
									
								
							@@ -1,31 +0,0 @@
 | 
				
			|||||||
#!/usr/bin/python3
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import re
 | 
					 | 
				
			||||||
import requests
 | 
					 | 
				
			||||||
from bs4 import BeautifulSoup
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def is_url(msg):
 | 
					 | 
				
			||||||
   regex = r"(https?:\/\/(?:www\.)?\S+)"
 | 
					 | 
				
			||||||
   match = re.search(regex, msg)
 | 
					 | 
				
			||||||
   if match:
 | 
					 | 
				
			||||||
      url = match.group(1)
 | 
					 | 
				
			||||||
      return url
 | 
					 | 
				
			||||||
   else:
 | 
					 | 
				
			||||||
      return None
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def get_data(url):
 | 
					 | 
				
			||||||
   r = requests.get(url)
 | 
					 | 
				
			||||||
   data = r.text
 | 
					 | 
				
			||||||
   r.close()
 | 
					 | 
				
			||||||
   return data
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
def get_title(url):
 | 
					 | 
				
			||||||
   data = get_data(url)
 | 
					 | 
				
			||||||
   soup = BeautifulSoup(data, 'html.parser')
 | 
					 | 
				
			||||||
   title = soup.title.string
 | 
					 | 
				
			||||||
   del soup
 | 
					 | 
				
			||||||
   return title
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user