Skip to content

Instantly share code, notes, and snippets.

@erayarslan
Created January 14, 2014 06:19
Show Gist options
  • Save erayarslan/8413902 to your computer and use it in GitHub Desktop.
Save erayarslan/8413902 to your computer and use it in GitHub Desktop.
sozluksau.com Topic Snippet Code
# author : guguluk
# libs / for fails follow easy_install command
import urllib2
from lxml import etree
# biggest nick id
nickId = -1
# nick dict
nickArray = []
# count by nick
countArray = []
def checkNick(nick):
i = 0
for m in nickArray:
if m==nick:
return i
i = i + 1
return -1
# total entry count
total = 0
# author dict username
me = "guguluk"
# entry count
count = 0;
# messages class
class result:
me = "DONT SHOT ITS ME;)"
# dict url
sozluksau = "http://www.sozluksau.com"
mainHTML = urllib2.urlopen(sozluksau).read()
mainTree = etree.HTML(mainHTML)
mainR = mainTree.xpath('//*[@id="baslik_listesi"]/a')
for i in range(0,len(mainR)-1):
value = mainR[i][0].text
link = sozluksau+mainR[i].attrib["href"][5:-1]
topicHTML = urllib2.urlopen(link).read()
topicTree = etree.HTML(topicHTML)
topicR = topicTree.xpath('//*[@id="govde"]/div[2]/p[2]/font[2]/a[1]')
r = checkNick(topicR[0].text)
if r == -1:
nickArray.append(topicR[0].text)
countArray.append(1)
else:
countArray[r] = countArray[r]+1
if topicR[0].text==me:
print result.me
count = count + 1
else:
print "#" + topicR[0].text
total = total + 1
print "####################"
print me + " > " + str(count)
print "total" + " > " + str(total)
print "result" + " > " + "%" + str((float(count)/total)*100)
print "####################"
for i in range(0,len(nickArray)):
if i == 0:
nickId = 0
else:
if countArray[i]>countArray[nickId]:
nickId=i
print nickArray[i] + " > " + str(countArray[i])
print "####################"
print "Most sharer >" + nickArray[nickId] + "<" + " with " + str(countArray[nickId]) + " entry count! ;)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment