我有一个包含磁力种子列表的蜘蛛的python列表。现在我该如何将这个列表/磁盘洪流存储在数据库字段中? 这是代码:如何将洪流链接存储在数据库中?
class MySpider(BaseSpider):
name = "myspider"
allowed_domains = ["thepiratebay.se"]
base_url = "http://www.thepiratebay.se/search/%s/"
start_urls = []
def __init__(self, *args, **kwargs):
movies = Movie.objects.all()
for movie in movies:
self.start_urls.append(self.base_url % movie.name)
super(MySpider, self).__init__(*args, **kwargs)
def parse(self, response):
self.log('Hi, this is an item page! %s' % response.url)
hxs = HtmlXPathSelector(response)
items = hxs.select('//table/tr/td[contains(@class, "detName")]')
item = items
item_name = hxs.select('//a[@class="detLink"]/text()').extract()[1]
print item_name #list containing movie names
torrent_link = hxs.select('//a[@title="Download this torrent using magnet"]/@href').extract()[1]
print torrent_link # torrent_link contains list of torrent links
现在我想保存在数据库中的这些链接???怎么做 ???
你试过的是什么不起作用? – webjunkie
为了帮助我们需要更多信息。什么数据库引擎?什么是表结构?什么python库?但主要是我们需要看看你已经尝试了什么? –
我获得了蜘蛛的磁力洪流列表,并创建了一个模型,其中的链接将被保存,但我不知道如何在数据库字段中保存洪流链接.. –