我在一个包含磁铁种子列表的蜘蛛中有一个 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
现在我想将这些链接保存在数据库中???怎么做 ???