'For Bucky' My first python program

+3 Isaiah Rahmany · August 27, 2014
Hey bucky I have made my first python program it uses beautifulsoup and python 3.4.1 and takes in usernames from twitter in a file and gives you info on them in an output file!

I think it's kinda cool idk...



from bs4 import BeautifulSoup
import os
import requests
import urllib.request
import urllib.parse
import sys


file = open('users.txt', 'r')
file1 = open('output.txt', 'w')
tweetname = file.read().splitlines()
file.close()
tweet = list(tweetname)
b = len(tweet)



a = 0


def main(a,b):
    if a == b:
        file1.close()
        input("Press any key to continue")
        sys.exit()
    twitter = str(tweet[a])
    os.system('cls')
    url = "http://gettwitterid.com/?user_name=" + twitter + "&submit=GET+USER+ID"
    r  = requests.get(url)
    soup = BeautifulSoup(r.text)
    htmlid = soup.findAll('table')[0].findAll('tr')[0].findAll('td')[1].p.string
    htmlname = soup.findAll('table')[0].findAll('tr')[1].findAll('td')[1].p.string
    htmlscreen = soup.findAll('table')[0].findAll('tr')[2].findAll('td')[1].p.string
    htmlfollow = soup.findAll('table')[0].findAll('tr')[3].findAll('td')[1].p.string
    htmlstatus = soup.findAll('table')[0].findAll('tr')[4].findAll('td')[1].p.string
    
    file1.write("Twitter User ID = " + htmlid + "\n")
    file1.write("Full Name = " + htmlname + "\n")
    file1.write("Screen Name = " + htmlscreen + "\n")
    file1.write("Total Followers = " + htmlfollow + "\n")
    file1.write("Total Statuses = " + htmlstatus + "\n")
    file1.write("" + "\n")
    
    
    a+=1
    main(a,b)
   
main(a,b)

    
   



here are the results:


Twitter User ID = 21447363
Full Name = KATY PERRY
Screen Name = katyperry
Total Followers = 56,047,826
Total Statuses = 6,036

Twitter User ID = 27260086
Full Name = Justin Bieber
Screen Name = justinbieber
Total Followers = 53,978,008
Total Statuses = 27,560

Twitter User ID = 813286
Full Name = Barack Obama
Screen Name = BarackObama
Total Followers = 45,633,058
Total Statuses = 12,324

Twitter User ID = 10228272
Full Name = YouTube
Screen Name = YouTube
Total Followers = 44,666,884
Total Statuses = 11,099

Twitter User ID = 17919972
Full Name = Taylor Swift
Screen Name = taylorswift13
Total Followers = 43,021,837
Total Statuses = 2,344

Twitter User ID = 14230524
Full Name = Lady Gaga
Screen Name = ladygaga
Total Followers = 41,973,303
Total Statuses = 5,259

Twitter User ID = 16409683
Full Name = Britney Spears
Screen Name = britneyspears
Total Followers = 38,595,965
Total Statuses = 3,733

Twitter User ID = 79293791
Full Name = Rihanna
Screen Name = rihanna
Total Followers = 36,925,604
Total Statuses = 9,288

Twitter User ID = 180505807
Full Name = Instagram
Screen Name = instagram
Total Followers = 34,662,333
Total Statuses = 5,339

Twitter User ID = 26565946
Full Name = Justin Timberlake
Screen Name = jtimberlake
Total Followers = 34,215,177
Total Statuses = 2,491

Twitter User ID = 31361166
Full Name = Zaira Scotti
Screen Name = ZairaAmaterasu
Total Followers = 6,648
Total Statuses = 33,197

Twitter User ID = 783214
Full Name = Twitter
Screen Name = twitter
Total Followers = 31,819,288
Total Statuses = 1,796

Twitter User ID = 15846407
Full Name = Ellen DeGeneres
Screen Name = TheEllenShow
Total Followers = 30,814,613
Total Statuses = 9,188

Twitter User ID = 155659213
Full Name = Cristiano Ronaldo
Screen Name = Cristiano
Total Followers = 29,294,830
Total Statuses = 2,098

Twitter User ID = 85603854
Full Name = Jennifer Lopez
Screen Name = JLo
Total Followers = 28,899,181
Total Statuses = 4,531

Twitter User ID = 44409004
Full Name = Shakira
Screen Name = shakira
Total Followers = 26,666,608
Total Statuses = 3,145

Twitter User ID = 19397785
Full Name = Oprah Winfrey
Screen Name = Oprah
Total Followers = 25,176,767
Total Statuses = 9,479

Twitter User ID = 28706024
Full Name = P!nk
Screen Name = Pink
Total Followers = 24,583,803
Total Statuses = 5,418

Twitter User ID = 21111883
Full Name = Demi Lovato
Screen Name = ddlovato
Total Followers = 24,151,386
Total Statuses = 12,014

Twitter User ID = 25365536
Full Name = Kim Kardashian West
Screen Name = KimKardashian
Total Followers = 23,100,899
Total Statuses = 17,916

Twitter User ID = 23375688
Full Name = Selena Gomez
Screen Name = selenagomez
Total Followers = 22,423,948
Total Statuses = 3,445

Twitter User ID = 15392457
Full Name = Joshua To
Screen Name = joshto
Total Followers = 3,711
Total Statuses = 2,632

Twitter User ID = 181561712
Full Name = Harry Styles
Screen Name = Harry_Styles
Total Followers = 21,803,570
Total Statuses = 4,838

Twitter User ID = 184910040
Full Name = Adele
Screen Name = OfficialAdele
Total Followers = 20,859,110
Total Statuses = 213

Twitter User ID = 60865434
Full Name = Kaka
Screen Name = KAKA
Total Followers = 20,629,992
Total Statuses = 3,629

Twitter User ID = 209708391
Full Name = One Direction
Screen Name = onedirection
Total Followers = 20,282,396
Total Statuses = 6,979

Twitter User ID = 105119490
Full Name = Niall Horan
Screen Name = NiallOfficial
Total Followers = 19,655,527
Total Statuses = 9,465

Twitter User ID = 35094637
Full Name = Alicia Keys
Screen Name = aliciakeys
Total Followers = 19,557,543
Total Statuses = 4,837

Twitter User ID = 100220864
Full Name = Bruno Mars
Screen Name = BrunoMars
Total Followers = 18,694,094
Total Statuses = 3,223

Twitter User ID = 22940219
Full Name = Marshall Mathers
Screen Name = Eminem
Total Followers = 18,622,145
Total Statuses = 373

Twitter User ID = 268414482
Full Name = Miley Ray Cyrus
Screen Name = MileyCyrus
Total Followers = 18,428,758
Total Statuses = 7,750

Twitter User ID = 428333
Full Name = CNN Breaking News
Screen Name = cnnbrk
Total Followers = 18,393,124
Total Statuses = 34,481

Twitter User ID = 179908477
Full Name = Mark W. Bennett
Screen Name = itretrospective
Total Followers = 3,154
Total Statuses = 1,296

Twitter User ID = 35787166
Full Name = Anaconda
Screen Name = NICKIMINAJ
Total Followers = 17,972,712
Total Statuses = 29,276

Twitter User ID = 34507480
Full Name = Ariana Grande
Screen Name = ArianaGrande
Total Followers = 17,806,464
Total Statuses = 34,859

Twitter User ID = 158314798
Full Name = the man in black
Screen Name = Real_Liam_Payne
Total Followers = 17,760,807
Total Statuses = 8,292

Twitter User ID = 116362700
Full Name = Lil Wayne WEEZY F
Screen Name = LilTunechi
Total Followers = 17,676,527
Total Statuses = 1,060

Twitter User ID = 31927467
Full Name = Pitbull
Screen Name = pitbull
Total Followers = 17,537,873
Total Statuses = 5,792

and so on...

Post a Reply

Replies

Oldest  Newest  Rating
+3 Abdullah Nauman · August 30, 2014
This is your FIRST Python Program?  

My first Python Program was this: 


print("Hello World"); 



  :) :) :) :) :) :) :) Lol :) :) :) :) :) :) :) 
+1 Isaiah Rahmany · August 27, 2014
Lol I am sorta abusing the website but oh well
+1 Predrag Kostic · August 28, 2014
Neat
+1 Kaveh Greenwood · August 30, 2014
Sweet deal! It's great to see the work of others on here.
+1 Jake Scaife · August 30, 2014
Looks pretty cool. Plus the extensive testing.. it must work! ;)
0 Isaiah Rahmany · August 28, 2014
Thank you :)
0 Isaiah Rahmany · August 29, 2014
lol no...
  • 1

Python

107,208 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator