Monday, January 5, 2015

Python Web scrapping with BeautifulSoup-Get all the links from website


#code for printing all the link from website using beautifulsoup4
import urllib2
from bs4 import BeautifulSoup
#import webbrowser


redditFile = urllib2.urlopen("http://www.oceanwebtech.com")
redditHtml = redditFile.read()
redditFile.close()

soup = BeautifulSoup(redditHtml)
redditAll = soup.find_all("a")
for links in soup.find_all('a'):
    print (links.get('href'))
    #webbrowser.open(links.get('href'))#for opening all the links

Opening All the links in list-Python

Opening All the link in list.
import webbrowser
urls =['http://odesk.com','http://elance.com','http://freelancer.com','http://twitter.com','http://facebook.com']
for i in urls:
    webbrowser.open(i)
   

Sunday, January 4, 2015

How To: Change Your Ip In Less Then 1 Minute

Follow the  steps to change your IP in less 1 minute.
1. Click on "Start" in the bottom left hand corner of screen
2. Click on "Run"
3. Type in "command" and hit ok

You should now be at an MSDOS prompt screen.

4. Type "ipconfig /release" just like that, and hit "enter"
5. Type "exit" and leave the prompt
6. Right-click on "Network Places" or "My Network Places" on your desktop.
7. Click on "properties"

You should now be on a screen with something titled "Local Area Connection", or something close to that, and, if you have a network hooked up, all of your other networks.

8. Right click on "Local Area Connection" and click "properties"
9. Double-click on the "Internet Protocol (TCP/IP)" from the list under the "General" tab
10. Click on "Use the following IP address" under the "General" tab
11. Create an IP address (It doesn't matter what it is. I just type 1 and 2 until i fill the area up).
12. Press "Tab" and it should automatically fill in the "Subnet Mask" section with default numbers.
13. Hit the "Ok" button here
14. Hit the "Ok" button again

You should now be back to the "Local Area Connection" screen.

15. Right-click back on "Local Area Connection" and go to properties again.
16. Go back to the "TCP/IP" settings
17. This time, select "Obtain an IP address automatically"
tongue.gif 18. Hit "Ok"
19. Hit "Ok" again
20. Now you have a new IP address

With a little practice, you can easily get this process down to 15-20 seconds.

Note:
This only changes your dynamic IP address, not your ISP/IP address. If you plan on hacking a website with this trick be extremely careful, because if they try a little, they can trace it back

Get User details Just by Entering Username-Facebook Scraping

Here is the code for Obtaining User Details
import urllib2
import json
def main():
    username_input =raw_input("Username: ")

    #e.g. http://facebook.com/sentiking, sentiking is the username

    #list_username = ["sentiking", "nasjay", "jumbogiant", "sagarsharma"]
    list_usernames = []
    list_companies.append(username_input)
    graph_url = "http://graph.facebook.com/"
   
    for user in list_usernames:
    #make graph api url with company username
        current_page = graph_url + user
       
        #open public page in facebook graph api
        web_response = urllib2.urlopen(current_page)
        readable_page = web_response.read()
        json_fbpage = json.loads(readable_page)
       # print json_fbpage
       
        #print page data to console
        print " Username: " + user
        print " User_id: " +json_fbpage["id"]
        print " Name: " +json_fbpage["name"]
        print " First_name: " +json_fbpage["first_name"]
        print " Last_name: " +json_fbpage["last_name"]
        print " Gender: " +json_fbpage["gender"]
        print " URL: " +json_fbpage["link"]
        print "            "
       
       
if __name__ == "__main__":
main()



####OUTPUT###
Username: smilingsenti
 Username: smilingsenti
 User_id: 100001307691331
 Name: Sentiking
 First_name: Sentiking
 Last_name: Sentiking
 Gender: male
 URL: https://www.facebook.com/smilingsenti