Created
July 29, 2016 14:33
-
-
Save manashmandal/daed7cd8bd59bf29ffe417c5b5005b6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from selenium import webdriver | |
from bs4 import BeautifulSoup | |
news_link = 'http://www.dhakatribune.com/tags/bangladesh%20garments' | |
news_class = 'entry-title' | |
class GetNewsLinks(): | |
def __init__(self): | |
self.chrome = webdriver.Chrome() | |
self.chrome.get(news_link) | |
self.current_url = '' | |
def getLinksFromCurrentPage(self): | |
self.current_url = self.chrome.current_url | |
links = self.chrome.find_elements_by_class_name(news_class) | |
for link in links: | |
print link.get_attribute('href') | |
def __del__(self): | |
self.chrome.close() | |
if __name__ == '__main__': | |
getNewsLink = GetNewsLinks() | |
getNewsLink.getLinksFromCurrentPage() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment