no output

20 views
Skip to first unread message

metin yildirim

unread,
Oct 23, 2016, 10:48:40 PM10/23/16
to beautifulsoup
ı am new in python . the code is not giving any arrors put does not supply the info it supposed to do so. i could not resolve the  problem . if you could help me put it would be  greatly appricated
my desired outputs fro twitter is the twits, sender info, url and the date the code is submitter hereunder. i
from bs4 import BeautifulSoup
import urllib.request
import openpyxl
wb= openpyxl.load_workbook('dene1.xlsx')
sheet=wb.get_sheet_by_name('Sayfa1')
headers = {}
headers['User-Agent'] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17"
req = urllib.request.Request(url, headers = headers)
resp = urllib.request.urlopen(req)
respData = resp.read()
soup = BeautifulSoup(respData , 'html.parser')
gdata = soup.find_all("div", {"class": "content"})
for item in gdata:
try:
items2 = item.find('a', {'class': 'tweet-timestamp js-permalink js-nav js-tooltip'})
items21=items2.get('href')
items22=items2.get('title')
except:
pass
try:
items1 = item.find('span', {'class': 'username js-action-profile-name'}).text
except:
pass
try:
items3 = item.find('p', {'class': 'TweetTextSize js-tweet-text tweet-text'}).text
sheet1=sheet.append([items21, items22,items1,items3])
except:
pass
wb.save('dene1.xlsx')
Reply all
Reply to author
Forward
0 new messages