예제 #1
0
 def handle(self, *arguments, **options):
     print 'START'
     i = 1
     block = soup.find_all('div', {'class': 'item-container'})
     for l in block:
         record = News()
         record.title = 'Title %s' % i
         findText = l.findNext('div', {'class': 'issue-item'}).find_all('p')
         a = ''
         for m in findText:
             a += m.text
         record.content = a
         record.urls = l.find('a', {
             'class': 'issue-item-title'
         }).get('href', 'http')
         record.save()
         print 'Saving %s' % i
         i += 1
예제 #2
0
            help='Url address',
        )

    def handle(self, *args, **options):
        # ...
        print 'Start'
<<<<<<< HEAD
        #News.objects.delete()
        #for r in News.objects.filter(pk__gt=10):
        #    print r.delete()
        
        return True
        for i in range(1,200):
            record = News()
            record.title = 'Title %s' % i
            record.content = 'Content %s' % i
            record.save() 
            print 'Saving %s' % i
        
        
        if options['url']:
            print 'Loadd from %s' % options['url']
        # ...
        print 'End'
        
=======
        import requests
        from bs4 import BeautifulSoup

        url = 'https://pythondigest.ru/'
        r = requests.get( url )