Saturday, 26 November 2016

python API for assamese news papers Pratidin

python API for assamese news papers Pratidin

Recently this news site has changed their way of publishing new . So this one is new way to drag their papers to your pc .


URL: http://www.asomiyapratidin.in/


import os,requests,bs4
os.system('rm -vfr *_pratidin*')
t=raw_input('date formate 22-11-2016: ')
os.system('mkdir %s_pratidin'%t)
os.chdir('%s_pratidin'%t)
a=requests.get('http://www.asomiyapratidin.in/np-images/small/%s/'%t)
r=bs4.BeautifulSoup(a.content)
r.find_all('a')
for i in range(len(r.find_all('a'))):
        os.system('mkdir %i'%(i+1))
        os.chdir('%i'%(i+1))
        c=requests.get('http://www.asomiyapratidin.in/np-images/small/27-12-2016/%i/'%(i+1))
        d=bs4.BeautifulSoup(c.content)
        for e in range(len(d.find_all('a'))):
                os.system('wget http://www.asomiyapratidin.in/np-images/small/27-12-2016/%i/%i.jpg'%(i+1,e+1))
        os.chdir('../')




or


import os,requests,bs4
os.system('rm -vfr *_pratidin*')
t='27-12-2016'
#t=raw_input('date formate 22-11-2016: ')
os.system('mkdir %s_pratidin'%t)
os.chdir('%s_pratidin'%t)
a=requests.get('http://www.asomiyapratidin.in/np-images/small/%s/'%t)
r=bs4.BeautifulSoup(a.content)
r.find_all('a')
for i in range(len(r.find_all('a'))):
        os.system('mkdir %i'%(i+1))
        os.chdir('%i'%(i+1))
        c=requests.get('http://www.asomiyapratidin.in/np-images/small/27-12-2016/%i/'%(i+1))
        d=bs4.BeautifulSoup(c.content)
        for e in range(len(d.find_all('a'))):
                os.system('wget http://www.asomiyapratidin.in/np-images/small/27-12-2016/%i/%i.jpg'%(i+1,e+1))
        os.chdir('../')



Bellow is a ss how it will work .




Connect With Me: Facebook

No comments:

Post a Comment

Popular Posts