├── .gitignore
├── README.md
├── automate your hack nyu form
├── __init__.py
├── data1.csv
├── fill_up_nyu.py
└── hack_nyu.py
├── download all django videos
├── __init__.py
├── download_videos_godjango.py
└── go_django.py
├── html dom tree.png
├── identify xpath.md
├── scrape all donald trump quotes
├── __init__.py
├── brain_quote_page.py
├── extract_donald_trump_quotes.py
└── write_data_1.csv
├── scrape top tech news from hacker news website
├── __init__.py
├── extact_hacker_news.py
├── hacker_news.py
└── write_data_1.csv
├── selenium-installation-guide.md
└── short tutorial to handle csv files
├── __init__.py
└── read_write_csv.py
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Python template
2 | # Byte-compiled / optimized / DLL files
3 | __pycache__/
4 | *.py[cod]
5 | *$py.class
6 |
7 | # C extensions
8 | *.so
9 | .idea
10 | # Distribution / packaging
11 | .Python
12 | env/
13 | build/
14 | develop-eggs/
15 | dist/
16 | downloads/
17 | eggs/
18 | .eggs/
19 | lib/
20 | lib64/
21 | parts/
22 | sdist/
23 | var/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *,cover
47 |
48 | # Translations
49 | *.mo
50 | *.pot
51 |
52 | # Django stuff:
53 | *.log
54 |
55 | # Sphinx documentation
56 | docs/_build/
57 |
58 | # PyBuilder
59 | target/
60 |
61 | # Created by .ignore support plugin (hsz.mobi)
62 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Web-Scraping using Selenium
2 |
3 | # What is the need of Selenium?
4 |
5 | Some websites don't like to be scrapped and in that case you need to disguise your webscraping bot as a Human Being.
6 |
7 |
8 | # What is locator or css selector or xpath?
9 |
10 | Locator can be termed as an address that identifies a web element uniquely within the webpage. Locators are the HTML
11 | properties of a web element which tells the Selenium about the web element it need to perform action on.
12 |
13 | There is a diverse range of web elements. The most common amongst them are:
14 |
15 | Text box
16 | Button
17 | Drop Down
18 | Hyperlink
19 | Check Box
20 | Radio Button
21 |
22 | Types of Locators in Selenium
23 |
24 | Photo Credit - www.softwaretestinghelp.com
25 |
26 | 
27 |
28 |
29 | **XPATH**
30 |
31 | Xpath is used to locate a web element based on its XML path. XML stands
32 | for Extensible Markup Language and is used to store, organize and transport
33 | arbitrary data. It stores data in a key-value pair which is very much similar
34 | to HTML tags. Both being mark up languages and since they fall under the same
35 | umbrella, xpath can be used to locate HTML elements.
36 |
37 | The fundamental behind locating elements using Xpath is the traversing between
38 | various elements across the entire page and thus enabling a user to find an element with the reference of another element.
39 |
40 | **CSS-Selector**
41 |
42 | CSS Selector is combination of an element selector and a selector value which identifies the web element within a web page.
43 | The composite of element selector and selector value is known as Selector Pattern.
44 |
45 | Photo-Credit - www.softwaretestinghelp.com
46 |
47 | Primitive types of CSS Selector
48 |
49 | 
50 |
51 | [Different Types of CSS Selector](http://www.w3schools.com/cssref/css_selectors.asp)
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/automate your hack nyu form/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakeshsukla53/webscraping-selenium/1dabda09afb57a18994a3355f24c300447e804a8/automate your hack nyu form/__init__.py
--------------------------------------------------------------------------------
/automate your hack nyu form/data1.csv:
--------------------------------------------------------------------------------
1 | first_name,last_name,email_id
2 | Terri, Burns, terri.burns@nyu.edu
3 | Freia, Lobo, freia@nyu.edu
4 | jhishan, khan, jhishan@nyu.edu
5 |
6 |
--------------------------------------------------------------------------------
/automate your hack nyu form/fill_up_nyu.py:
--------------------------------------------------------------------------------
1 | from selenium import webdriver
2 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
3 | from selenium.webdriver.common.by import By
4 | from selenium.webdriver.support.ui import WebDriverWait
5 | from selenium.webdriver.support import expected_conditions as EC
6 | import csv
7 | from time import sleep
8 |
9 |
10 | # set the scrolling behavior to down
11 | DesiredCapabilities.FIREFOX["elementScrollBehavior"] = 1
12 |
13 |
14 | def fill_up_hack_nyu(student):
15 | """ automate your hack nyu form using selenium"""
16 | driver = webdriver.Firefox()
17 | wait = WebDriverWait(driver, 10)
18 | # load the page
19 | driver.get("http://hacknyu.org/signup")
20 | # get the form element
21 | form = driver.find_element_by_css_selector("form[name='signupForm']")
22 | # fill the fields
23 | form.find_element_by_css_selector("input[name='firstName']").send_keys(student['first_name'])
24 | form.find_element_by_css_selector("input[name='lastName']").send_keys(student['last_name'])
25 | form.find_element_by_css_selector("input[name='email']").send_keys(student['email_id'])
26 | form.find_element_by_css_selector("input[name='password']").send_keys("technyu")
27 | # click and accept terms
28 | form.find_element_by_xpath("//input[@name='terms']/..").click()
29 | wait.until(EC.presence_of_element_located((By.XPATH, "//button[.='Accept']"))).click()
30 | wait.until_not(EC.presence_of_element_located((By.CSS_SELECTOR, ".modal")))
31 | # click on submit
32 | form.find_element_by_css_selector("button[type='submit']").click()
33 | driver.quit()
34 |
35 |
36 | def read_csv_files():
37 | with open('data1.csv', 'r+') as data_file:
38 | data = csv.DictReader(data_file)
39 | for row in data:
40 | fill_up_hack_nyu(row)
41 | sleep(1)
42 |
43 | read_csv_files()
44 |
--------------------------------------------------------------------------------
/automate your hack nyu form/hack_nyu.py:
--------------------------------------------------------------------------------
1 | class HackNNYU(object):
2 | first_name = 'input[ng-model="credentials.first_name"]'
3 | last_name = 'input[ng-model="credentials.last_name"]'
4 | email = '.col-sm-12>input[ng-model="credentials.email"]'
5 | password = '.col-sm-12>input[ng-model="credentials.password"]'
6 | agree_checkbox = '.ng-binding>input[ng-model="checkModel"]'
7 | sign_up_button = 'div>button[type="submit"]'
8 | accept_button = 'button[ng-click="positive()"]'
9 |
--------------------------------------------------------------------------------
/download all django videos/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakeshsukla53/webscraping-selenium/1dabda09afb57a18994a3355f24c300447e804a8/download all django videos/__init__.py
--------------------------------------------------------------------------------
/download all django videos/download_videos_godjango.py:
--------------------------------------------------------------------------------
1 | from selenium import webdriver
2 | from go_django import GoDjango
3 | from selenium.webdriver.support import expected_conditions as EC
4 | from selenium.webdriver.support.ui import WebDriverWait
5 | from selenium.webdriver.common.by import By
6 | from time import sleep
7 |
8 |
9 | def download_videos():
10 | """ download all videos from www.godjango.com """
11 | driver = webdriver.Firefox()
12 | driver.get('https://godjango.com/browse/')
13 | WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.CSS_SELECTOR, GoDjango.first_video_title)))
14 | while True:
15 | for element in range(0, 10):
16 | all_video_elements = driver.find_elements_by_css_selector(GoDjango.first_video_title)
17 | all_video_elements[element].click()
18 | try:
19 | print driver.find_element_by_css_selector(GoDjango.video_download_link).get_attribute('src')
20 | except:
21 | print "Video is private"
22 | driver.execute_script("window.history.go(-1)")
23 | driver.execute_script("window.scrollTo(0, 465);")
24 | driver.execute_script("window.scrollTo(0, 4650);")
25 | sleep(1)
26 | driver.find_element_by_css_selector(GoDjango.next_button_click).click()
27 | driver.quit()
28 |
29 | if __name__ == '__main__':
30 | download_videos()
31 |
32 |
--------------------------------------------------------------------------------
/download all django videos/go_django.py:
--------------------------------------------------------------------------------
1 | class GoDjango(object):
2 | pro_video_tag = '.media.episode-list-item.padding-15 div div span'
3 | video_container = '.media.episode-list-item.padding-15'
4 | first_video_title = 'h4[class="media-heading"] a'
5 | next_button_click = 'li[class="active"] + li a'
6 | video_download_link = 'div[class="video-description"] + iframe'
7 |
--------------------------------------------------------------------------------
/html dom tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakeshsukla53/webscraping-selenium/1dabda09afb57a18994a3355f24c300447e804a8/html dom tree.png
--------------------------------------------------------------------------------
/identify xpath.md:
--------------------------------------------------------------------------------
1 | XPath locator examples
2 |
3 | To find the link in this page:
4 |
5 |
6 | The fox jumped over the lazy brown dog .
7 |
8 |
9 | A raw XPath traverses the hierarchy from the root element of the document (page) to the desired element:
10 |
11 | /html/body/p/a
12 |
13 |
14 | Child of Element ID
15 |
16 | XPath can find an element by ID like this:
17 |
18 | //*[@id="element_id"]
19 |
20 | So if you need to find an element that is near another element with an ID, like the link in this example:
21 |
22 |
23 | The fox jumped over the lazy brown dog .
24 |
25 |
26 | you could try an XPath like this to find the first link that is a child of the element with ID=”fox”:
27 |
28 | //*[@id="fox"]/a
29 |
30 |
31 | Button Text
32 |
33 | There are two ways to declare a standard button in HTML, discounting the many ways to make something that looks like a button, but is not. To determine how an element is declared in the HTML, see how to inspect an element in the browser.
34 |
35 | If the button is declared with the tag and the button says “press me”, try this:
36 |
37 | //button(contains(., 'press me')]
38 |
39 | If the button is a form submit button (declared with the tag and type=”submit” or =”button”) and says “press me”, try this:
40 |
41 | //input[@value='press me']
42 |
43 |
44 | Text of element
45 |
46 | Sometimes a bit of text is styled as a link or button. To find it, try this:
47 |
48 | //*[text()='the visible text']
49 |
50 |
51 | The Nth element
52 |
53 | To find the Nth element, you must surround your XPath in ()s and then specify the Nth using [n], like this:
54 |
55 | (xpath)[n]
56 |
57 | A very simple example – find the 3rd link on a page:
58 |
59 | (//a)[3]
60 |
61 | To find the 4rd text input field on a page:
62 |
63 | (//input[@type="text"])[4]
64 |
65 | You can also traverse from the indexed element. So, to find the link in the 2nd div with class ‘abc’:
66 |
67 | (//div[@class='abc'])[2]/a
--------------------------------------------------------------------------------
/scrape all donald trump quotes/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakeshsukla53/webscraping-selenium/1dabda09afb57a18994a3355f24c300447e804a8/scrape all donald trump quotes/__init__.py
--------------------------------------------------------------------------------
/scrape all donald trump quotes/brain_quote_page.py:
--------------------------------------------------------------------------------
1 |
2 | class BrainQuotePage(object):
3 | donald_trump_quotes = 'span[class="bqQuoteLink"]'
4 | donald_trump_links = 'span[class="bqQuoteLink"] a'
5 | donald_trump_next_page = '.pagination-sm .active + li a '
6 |
--------------------------------------------------------------------------------
/scrape all donald trump quotes/extract_donald_trump_quotes.py:
--------------------------------------------------------------------------------
1 | from selenium import webdriver
2 | from brain_quote_page import BrainQuotePage
3 |
4 |
5 | def extract_donald_trump_quotes():
6 | """ scrape all donald trump quotes """
7 | browser = webdriver.Firefox()
8 | browser.get('http://www.brainyquote.com/quotes/authors/d/donald_trump.html')
9 | while True:
10 | try:
11 | all_quotes = browser.find_elements_by_css_selector(BrainQuotePage.donald_trump_quotes)
12 | all_quote_links = browser.find_elements_by_css_selector(BrainQuotePage.donald_trump_links)
13 | for quotes, quote_link in zip(all_quotes, all_quote_links):
14 | # donald trump quote and link
15 | print (quotes.text, quote_link.get_attribute('href'))
16 | next_page = browser.find_element_by_css_selector(BrainQuotePage.donald_trump_next_page)
17 | next_page.click()
18 | except:
19 | # we have reached the last page
20 | break
21 | browser.quit()
22 |
23 | if __name__ == '__main__':
24 | extract_donald_trump_quotes()
25 |
--------------------------------------------------------------------------------
/scrape all donald trump quotes/write_data_1.csv:
--------------------------------------------------------------------------------
1 | Donald Trump,Quotes
2 | Sometimes by losing a battle you find a new way to win the war.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum383171.html
3 | I have a great relationship with the Mexican people.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717755.html
4 | "You have to think anyway, so why not think big?",http://www.brainyquote.com/quotes/quotes/d/donaldtrum153798.html
5 | "You know the funny thing, I don't get along with rich people. I get along with the middle class and the poor people better than I get along with the rich people.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum414743.html
6 | "Our politicians are stupid. And the Mexican government is much smarter, much sharper, much more cunning. And they send the bad ones over because they don't want to pay for them. They don't want to take care of them. Why should they when the stupid leaders of the United States will do it for them?",http://www.brainyquote.com/quotes/quotes/d/donaldtrum714310.html
7 | "That's one of the nice things. I mean, part of the beauty of me is that I'm very rich. So if I need $600 million, I can put $600 million myself. That's a huge advantage. I must tell you, that's a huge advantage over the other candidates.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum414742.html
8 | "Love him or hate him, Trump is a man who is certain about what he wants and sets out to get it, no holds barred. Women find his power almost as much of a turn-on as his money.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum401997.html
9 | "Part of being a winner is knowing when enough is enough. Sometimes you have to give up the fight and walk away, and move on to something that's more productive.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum153805.html
10 | "When somebody challenges you, fight back. Be brutal, be tough.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum384933.html
11 | "One of the key problems today is that politics is such a disgrace, good people don't go into government.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum173289.html
12 | What separates the winners from the losers is how a person reacts to each new twist of fate.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum130623.html
13 | "Experience taught me a few things. One is to listen to your gut, no matter how good something sounds on paper. The second is that you're generally better off sticking with what you know. And the third is that sometimes your best investments are the ones you don't make.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum153799.html
14 | "With out passion you don't have energy, with out energy you have nothing.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum384121.html
15 | My whole life is about winning. I don't lose often. I almost never lose.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733773.html
16 | "In the end, you're measured not by how much you undertake but by what you finally accomplish.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum400491.html
17 | So we really need jobs now. We have to take jobs away from other countries because other countries are taking our jobs. There is practically not a country that does business with the United States that isn't making - let's call it a very big profit. I mean China is going to make $300 billion on us at least this year.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum416722.html
18 | "As long as your going to be thinking anyway, think big.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum125612.html
19 | "Mitt - what I speak to Mitt Romney about is jobs. What I speak to Mitt Romney about is China, because he's got a great view on China and how they're trying to destroy our country by taking our jobs and making our product and manipulating their currency, so that it makes it almost impossible for our companies to compete.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum447868.html
20 | "If I were a liberal Democrat, people would say I'm the super genius of all time. The super genius of all time. If you're a conservative Republican, you've got to fight for your life. It's really an amazing thing.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717763.html
21 | I actually don't have a bad hairline.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733762.html
22 | Do you mind if I sit back a little? Because your breath is very bad.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum134614.html
23 | Private jets cost a lot of money.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717778.html
24 | "Obama has no solutions. Obama has failed the country and its great citizens, and they don't like it when somebody such as myself speaks the truth about this - it hurts too much.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum447876.html
25 | "I could never have imagined that firing 67 people on national television would actually make me more popular, especially with the younger generation.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum397807.html
26 | "People might not think that, but the Republicans have all of the cards. And this is the time to get rid of Obamacare. This is the time to make the great deal.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum416720.html
27 | "It's tangible, it's solid, it's beautiful. It's artistic, from my standpoint, and I just love real estate.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum173288.html
28 | "I have women working in high positions. I was one of the first people to put women in charge of big construction jobs. And, you know, I've had a great relationship with women.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733748.html
29 | I wasn't satisfied just to earn a good living. I was looking to make a statement.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum165644.html
30 | "I think George Will is somebody that said recently that the Republicans will not lose, as a Republican, that the Republicans will not win the election. I think it was a terrible statement.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum447866.html
31 | "A lot of people don't like to win. They actually don't know how to win, and they don't like to win because down deep inside they don't want to win.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733754.html
32 | "I am very, very proud to say that I am pro-life.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum714317.html
33 | I apologize when I'm wrong.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733746.html
34 | I deal with foreign countries. I made a lot of money dealing against China. I've made a lot of money dealing against many other countries.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717785.html
35 | I have a Bible near my bed.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733781.html
36 | "I have a great, great company. I employ thousands of people. And I'm very proud of the job I did.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum714316.html
37 | I have respect for Senator McCain. I used to like him a lot. I supported him. I raised a lot of money for his campaign against President Obama.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717786.html
38 | I have very good executives and great children. They're very good.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717790.html
39 | "I think that when you get right down to it, people do evolve on different issues. And, you know, I'm pro-life. And I was begrudgingly the other way.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733742.html
40 | I'm the Ernest Hemingway of 140 characters.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733836.html
41 | I'm worth far too much money. I don't need anybody's money.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717789.html
42 | I've become very successful over the years. I think I own among the greatest properties in the world.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733815.html
43 | People are tired of seeing politicians as all talk and no action.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733767.html
44 | "Remember, many Republicans didn't vote for Mitt Romney. He didn't inspire people.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733772.html
45 | "Saudi Arabia makes a billion dollars a day, okay? They make a billion dollars a day.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717762.html
46 | Somebody said I am the most popular person in Arizona because I am speaking the truth.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717767.html
47 | "We have to straighten out our country; we have to make our country great again, and we need energy and enthusiasm.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733747.html
48 | "We need a president with tremendous intelligence, smarts, cunning, strength and stamina.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733837.html
49 | "I built a great company, one of the - some of the most iconic assets in the world, $10 billion of net worth, more than $10 billion of net worth, and frankly, I had a great time doing it.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717777.html
50 | "I get a lot of credit for comb-overs. But it's not really a comb-over. It's sort of a little bit forward and back. I've combed it the same way for years. Same thing, every time.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733761.html
51 | "I played golf with my friends, and then I started to play with the hustlers. And I learned a lot. I learned about golf; I learned about gambling. I learned about everything.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717772.html
52 | "I think the World Trade Center should be rebuilt as the World Trade Center, only stronger and one story taller. I hate what they're doing with the World Trade Center site.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733828.html
53 | "Ronald Reagan became, you know, not only a Republican but a pretty conservative Repub - not the most. But a pretty conservative Republican. And he's somebody that I actually knew and liked. And he liked me. And I worked with him and helped him.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733741.html
54 | I have made really some significant deals because I play golf.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733818.html
55 | I love Neil Young. And he loves me! We have a great relationship.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733816.html
56 | I love Wingfoot; I'm a member of Wingfoot. It's a great course.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733803.html
57 | I rely on myself very much. I just think that you have an instinct and you go with it. Especially when it comes to deal-making and buying things.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733788.html
58 | I shake hands very gladly politically. I don't think you could be a politician if you didn't shake hands.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733750.html
59 | I think I will be a great president having to do with the military and also having to do with taking care of our vets.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733805.html
60 | I want to be a fair trader. I want to be a firm and fair trader.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733769.html
61 | I want to lower taxes for the middle class.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733808.html
62 | I was a great student. I was good at everything.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733749.html
63 | "I went to the Wharton School of Finance, the toughest place to get into. I was a great student.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733745.html
64 | I would say that I bought the land under which Trump Tower sits while playing golf.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733802.html
65 | "I'm a believer in the polls, by the way. Rarely do you see a poll that's very far off.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733775.html
66 | "I'm competitive, and I love to create challenges for myself. Maybe that's not always a good thing. It can make life complicated.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733780.html
67 | "I'm gonna keep Social Security without change, except I'm going to get rid of the waste, fraud, and abuse; same thing with Medicare.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733760.html
68 | I've always been covered by a press that's mostly financial press.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733787.html
69 | I've always felt comfortable in front of a camera. Either you're good at it or you're not good at it.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733792.html
70 | I've been making deals all my life.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733758.html
71 | I've created tens of thousands of jobs over the years.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733790.html
72 | "I've met some great people that deal with me in the press. I've also met some people that were very dishonorable, frankly.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733806.html
73 | Iran is not getting rid of any of its nuclear plants. They're not getting rid of anything.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717779.html
74 | It's my life. It just continues to go forward from 'The Apprentice.',http://www.brainyquote.com/quotes/quotes/d/donaldtrum733793.html
75 | Many agree that the worst thing that could ever happen is if Russia and China get closer.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717782.html
76 | "Obamacare is, number one and maybe least importantly, it's costing the country a fortune.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717794.html
77 | "People assume I'm a boiler ready to explode, but I actually have very low blood pressure, which is shocking to people.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733782.html
78 | Politicians can't manage. All they can do is talk.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717761.html
79 | Seth Meyers is highly overrated as a comedian.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733796.html
80 | "So many people are on television that don't know me, and they're like experts on me.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717792.html
81 | The Iranians and Persians are excellent at the art of negotiation.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum717781.html
82 | "The Pope, I hope, can only be scared by God.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717769.html
83 | "The USGA is terrific. I've designed my course in Bedminster to the highest standards of the USGA, and it's a very special course.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733831.html
84 | The way I run my business seems to be easier than the way I run my life.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733821.html
85 | "There's always opposition when you do something big. I do many things that are controversial. When people see it, they love it!",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733812.html
86 | "To me, I love real estate because you can feel it.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733791.html
87 | We've had soldiers that were so badly hurt and killed. I want their families to get something.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733743.html
88 | "Years ago, I predicted that Iran would take over Iraq. Iran and Iraq used to fight back and forth.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum717780.html
89 | "You don't get a standing ovation and get boos, by the way. They don't go hand in hand.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733789.html
90 | "We have to go see Bill Gates and a lot of different people that really understand what's happening. We have to talk to them, maybe in certain areas, closing that Internet up in some way. Somebody will say, 'Oh, freedom of speech, freedom of speech.' These are foolish people. We have a lot of foolish people.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum737831.html
91 | "At the Super Bowl, when Beyonce was thrusting her hips forward in a very suggestive manner, if someone else had done that, it would've been a national scandal. I thought it was ridiculous.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733797.html
92 | "Everybody has their detractors. Some people say arrogance, or whatever they may say. I only have one thing in mind, and that's doing a great job for the country.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733751.html
93 | "Everything I do in life is framed through the view of a businessman. That's my instinct. If I go into a pharmacy to buy shaving cream, then I'm going to look for the best deal on shaving cream.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733779.html
94 | "I describe Jeb Bush as a 'low-energy' individual, and unfortunately for him, that stuck. And it's true: he's a low-energy person. That doesn't make him a bad person.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733810.html
95 | "I do respect them; I have great respect for women. In fact, one of the reasons 'The Apprentice' was such a successful show for so many years, the audience of women was fantastic.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733752.html
96 | "I give to everybody. When they call, I give. And do you know what? When I need something from them two years later, three years later, I call them, they are there for me.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum714313.html
97 | "I had great relationship with the Hispanic - we had a lot of Hispanics in the school actually from different countries, Venezuela, from Brazil, and they all played soccer, and I was on the soccer team, and I developed great relationships with them.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733755.html
98 | I have the right temperament. I have the right leadership. I've built an incredible company. I went to a great school. I came out - I built an incredible company. I wrote the number one selling business book of all time: 'Trump: The Art of the Deal.',http://www.brainyquote.com/quotes/quotes/d/donaldtrum733764.html
99 | "I will tell you this: I have fun, a lot of fun with 'The Apprentice.' When I did the books - and now we have a book out. And all the time, books are prestigious. But there's sort of nothing like having the big hot show on television.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733827.html
100 | "I'll drink water. Sometimes tomato juice, which I like. Sometimes orange juice, which I like. I'll drink different things. But the Coke or Pepsi boosts you up a little.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733783.html
101 | "If you love what you do, if you love going to the office, if you really like it - not just say it, but really like it - it keeps you young and energised. I really love what I do.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733814.html
102 | "In real life, if I were firing you, I'd tell you what a great job you did, how fantastic you are, and how you can do better someplace else. If somebody steals, that's different, but generally speaking, you want to let them down as lightly as possible. It's not a very pleasant thing. I don't like firing people.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733835.html
103 | "My father was a successful real estate developer, and he was a very tough man but a good man. My father would always praise me. He always thought I was the smartest person.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733776.html
104 | "My father was very energetic; my mother was very energetic. He lived to a very old age, and so did my mother. I believe that I just have it from my father, from my parents. They had wonderful energy.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733757.html
105 | "One of the reasons that New York became great was that it's serviced by many, many different rivers and waterways. You have the Atlantic Ocean connected virtually right to it, and it's serviced by the East River and the Hudson River and lots of tributaries.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733823.html
106 | Owning great landmarks such as the Empire State Building or Trump Tower or the General Motors Building or the Plaza Hotel - there are certain just spectacular landmarks - it's an honor; it's really an honor.,http://www.brainyquote.com/quotes/quotes/d/donaldtrum733822.html
107 | "The early versions of 'Shell's Wonderful World of Golf' were great. It's sort of interesting: as it progressed, it became worse and worse, but the early versions were really fantastic with Jimmy Demaret and Gene Sarazen. They were classics.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733819.html
108 | "The golf facet of my life doesn't go with the rest of my life, which is a rough-and-tumble life. I work in real estate development, which is the toughest business, and I do it in the toughest city. I deal with ruthless people.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733832.html
109 | "The interesting thing is that everyone in golf is just nice. You learn a lot about people playing golf: their integrity, how they play under pressure.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733833.html
110 | "What I hate about Halle Berry is there's always drama around her. It's always fighting, automobile accidents, fistfights, boyfriends fighting ex-husbands for the child.",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733794.html
111 | "You've seen my statements; I do very well. I don't mind paying some taxes. The middle class is getting clobbered in this country. You know the middle class built this country, not the hedge fund guys, but I know people in hedge funds that pay almost nothing, and it's ridiculous, OK?",http://www.brainyquote.com/quotes/quotes/d/donaldtrum733809.html
112 |
--------------------------------------------------------------------------------
/scrape top tech news from hacker news website/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakeshsukla53/webscraping-selenium/1dabda09afb57a18994a3355f24c300447e804a8/scrape top tech news from hacker news website/__init__.py
--------------------------------------------------------------------------------
/scrape top tech news from hacker news website/extact_hacker_news.py:
--------------------------------------------------------------------------------
1 | from selenium import webdriver
2 | from hacker_news import HackerNews
3 | import csv
4 |
5 |
6 | def extract_top_news():
7 | """ scrape all top news from the hacker news website """
8 | data = []
9 | driver = webdriver.Firefox()
10 | driver.get('https://news.ycombinator.com/')
11 | element_list = driver.find_elements_by_css_selector(HackerNews.title_url)
12 | for element in element_list:
13 | try:
14 | title_url = (element.text.encode('ascii', 'replace'), element.get_attribute('href').encode('ascii', 'replace'))
15 | data.append(title_url)
16 | except Exception as e:
17 | print e
18 | headers = ('Title', 'Title_URL')
19 | with open('write_data_1.csv', 'w+') as data_file:
20 | writer = csv.writer(data_file)
21 | writer.writerow(headers)
22 | writer.writerows(data)
23 | driver.quit()
24 |
25 | if __name__ == '__main__':
26 | extract_top_news()
27 |
--------------------------------------------------------------------------------
/scrape top tech news from hacker news website/hacker_news.py:
--------------------------------------------------------------------------------
1 | class HackerNews(object):
2 | title_url = '.title>a'
3 |
--------------------------------------------------------------------------------
/scrape top tech news from hacker news website/write_data_1.csv:
--------------------------------------------------------------------------------
1 | Title,Title_URL
2 | Following a Select Statement Through Postgres Internals (2014),http://patshaughnessy.net/2014/10/13/following-a-select-statement-through-postgres-internals
3 | Maps Showing Where FBI Planes Are Watching from Above,http://www.buzzfeed.com/peteraldhous/spies-in-the-skies
4 | Pwncloud ? Bad crypto in the Owncloud encryption module,https://blog.hboeck.de/archives/880-Pwncloud-bad-crypto-in-the-Owncloud-encryption-module.html
5 | The Future Google Rackspace Power9 System,http://www.nextplatform.com/2016/04/06/inside-future-google-rackspace-power9-system/
6 | Performance Culture,http://joeduffyblog.com/2016/04/10/performance-culture/
7 | GCHQ 'intervened' over Harry Potter leak,http://www.bbc.co.uk/news/entertainment-arts-36010426
8 | What if the problem of poverty is that it?s profitable to other people?,http://www.theguardian.com/books/2016/apr/07/evicted-poverty-and-profit-in-the-american-city-matthew-desmond-review
9 | Blogless ? An articles-only publishing system for web writers,http://blogless.datenbrei.de/
10 | Meet the bughunters: the hackers in India protecting your data,http://www.theguardian.com/world/2016/apr/02/meet-the-bughunters-the-hackers-in-india-protecting-your-facebook-profile
11 | How Scams Worked in the 1800s,http://www.npr.org/sections/npr-history-dept/2015/02/12/385310877/how-scams-worked-in-the-1800s
12 | Flexport is hiring account execs in our NYC office,https://flexport.com/careers
13 | Top Hacker News Submissions by Year: 2009?2015,https://github.com/antontarasenko/smq/blob/master/reports/hackernews-top-submissions-by-year.md
14 | Algorithmically generated prior art,http://allpriorart.com/about/
15 | Your Life,http://some1else.github.io/life/
16 | Strategic Scala Style: Principle of Least Power,http://www.lihaoyi.com/post/StrategicScalaStylePrincipleofLeastPower.html
17 | Who will pay Puerto Rico's pensions?,http://www.reuters.com/investigates/special-report/usa-puertorico-pensions/
18 | "Economists Adding Up at Amazon.com, Microsoft, Google",http://www.investors.com/news/technology/amazon-microsoft-among-techs-that-say-employing-economists-adds-up/
19 | Sample workflow for LP digitization,http://manual.audacityteam.org/o/man/sample_workflow_for_lp_digitization.html
20 | Freelance Pilots,http://romansnitko.com/blog/freelance-pilots.html
21 | Stdio or iostreams? ? A Modest Alternative for C++,http://steved-imaginaryreal.blogspot.com/2016/04/stdio-or-iostreams-modest-alternative.html
22 | Analyzing the names of almost every Chinese restaurant in the U.S.,https://www.washingtonpost.com/news/wonk/wp/2016/04/08/we-analyzed-the-names-of-almost-every-chinese-restaurant-in-america-this-is-what-we-learned/
23 | Ammonia Is the Everest Base Camp for Clean Energy,http://thebreakthrough.org/issues/decarbonization/ammonia-is-everest-base-camp-for-clean-energy
24 | Pelikan: Twitter's unified cache back end,http://twitter.github.io/pelikan/
25 | 'Google Hobbies' proof of concept,https://blog.prototypr.io/google-hobbies-a-retrospective-on-a-new-feature-to-help-google-users-find-and-learn-new-skills-650947f0be#.c0si6ns7l
26 | Notes on 'Decisive: How to Make Better Choices in Life and Work',http://scattered-thoughts.net/blog/2016/04/10/notes-on-decisive-how-to-make-better-choices-in-life-and-work/
27 | "Network Monitoring, Moral Hazards and Crumple Zones",http://etherealmind.com/network-monitoring-moral-hazards-and-crumple-zones/
28 | A Wild Way to Save the Planet,https://newrepublic.com/article/130791/wild-way-save-planet
29 | QML for the Web,https://github.com/qmlweb/qmlweb
30 | Airbus thinks it has found a way to alleviate jet lag,http://www.economist.com/blogs/gulliver/2016/04/thatll-be-day?fsrc=scn/fb/te/bl/ed/thatllbethedayairbusthinksithasfoundawaytoalleviatejetlag
31 | Why volatile is hard to specify and implement,http://kristerw.blogspot.com/2016/04/why-volatile-is-hard-to-specify-and.html
32 | More,https://news.ycombinator.com/news?p=2
33 |
--------------------------------------------------------------------------------
/selenium-installation-guide.md:
--------------------------------------------------------------------------------
1 | Python, Selenium Installation Guide Download
2 |
3 | Installing Python and Selenium
4 |
5 | Installing Python:
6 |
7 | Windows : http://python.org/download/.
8 |
9 | Note : IF you are using Linux, MacOS X, Unix operating Systems then python will be installed by default with OS
10 |
11 | 1.What is PIP installer Tool?
12 | pip is a package management system used to install and manage software packages written in Python
13 | pip is a recursive acronym that can stand for either "Pip Installs Packages" or "Pip Installs Python
14 |
15 | 2.Where do we get this PIP Tool? And how to configure it in our Local Machines
16 |
17 | 3.Installing Selenium
18 | Use Below command on PIP to install Selenium Package
19 | pip install selenium
20 |
21 | This command will set up the Selenium WebDriver client library on your machine with all modules and classes that we will need to create automated scripts using Python
22 |
23 | 4.pip install -U selenium
24 | The optional –U flag will upgrade the existing version of the installed package
25 |
26 |
--------------------------------------------------------------------------------
/short tutorial to handle csv files/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rakeshsukla53/webscraping-selenium/1dabda09afb57a18994a3355f24c300447e804a8/short tutorial to handle csv files/__init__.py
--------------------------------------------------------------------------------
/short tutorial to handle csv files/read_write_csv.py:
--------------------------------------------------------------------------------
1 | import csv
2 |
3 | with open('data1.csv', 'r+') as data_file:
4 | data = csv.DictReader(data_file)
5 | for row in data:
6 | print(row)
7 |
8 | with open('data1.csv', 'r+') as data_file:
9 | data = csv.reader(data_file, delimiter='|')
10 | for row in data:
11 | print(row)
12 |
13 | data = [
14 | ('japanese', '5', '2001'),
15 | ('korean', '2', '1998'),
16 | ('german', '4', '2005'),
17 | ('english', '10', '1990'),
18 | ('tamil', '7', '2010'),
19 | ]
20 |
21 | headers = ('language', 'ability', 'started')
22 |
23 | with open('write_data_1.csv', 'w+') as data_file:
24 | writer = csv.writer(data_file)
25 | writer.writerow(headers)
26 | writer.writerows(data)
27 |
28 | data = [
29 | {'language': 'japanese', 'ability': '5', 'started': '2001'},
30 | {'language': 'korean', 'ability': '2', 'started': '1998'},
31 | {'language': 'german', 'ability': '4', 'started': '2005'},
32 | {'language': 'english', 'ability': '10', 'started': '1990'},
33 | {'language':'tamil', 'ability': '7', 'started': '2010'}
34 | ]
35 |
36 | with open('write_data_2.csv', 'w+') as data_file:
37 | writer = csv.DictWriter(data_file, fieldnames=headers)
38 | writer.writeheader()
39 | writer.writerows(data)
40 |
41 |
--------------------------------------------------------------------------------