我在爬imdb网站,然后存到mysql数据库里面。如这个
http://www.imdb.com/title/tt2474024/reviews?start=0,其中有一段是Surprisingly, it's not the talented leads that provide the most interest here … it's the story structure. As per the title, the story follows the couple's relationship over a five year period. The opening scene features Cathy reading and reacting to the break-up note left by Jamie. The second scene features Jamie describing his joy when he first falls for Cathy, as they romp in bed. See, Cathy's story goes from the end to the beginning, while Jamie's story goes from the beginning to the end … intersecting only at the marriage proposal in the park. It's a fascinating way to tell a story – not just two perspectives, but also in reverse order of each other!
提示存这一段的时候 Warning: Incorrect String value...,是那个省略号的问题。用chrome查看网页编码是 西欧语言windows-1252,用requests请求,可以看到r.encoding=iso-8859-1。我的mysql存储编码是默认的(应该是utf-8?),在代码里 我 是这样写的:
`content = p.text_content().strip('\n').decode('iso-8859-1').encode('utf8')`
decode那里换成windows-1252也不对。
也试过
`content = unicode(p.text_content().strip('\n'))`,都不行。需要怎么解决?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/175336
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.