new Shopify.OptionSelectors("product-select",{ product: {"ID":185310341,"Title":"10. Design | Siyah \u0026 beyaz kalpli",
我想得到“185310341”.我在谷歌搜索了几个小时但找不到任何东西,我希望你能帮助我.我怎么能刮掉那个JavaScript并得到那个ID?
我试过那段代码:
ID = sel.search('"ID":(.*?),',text).group(1)print ID
但我得到了:
exceptions.AttributeError: 'Selector' object has no attribute 'search'解决方法 Scrapy选择器的正则表达式为 built-in support:
sel.xpath('<xpath_to_find_the_element_text>').re(r'"ID":(\d+)')
演示显示这个特定正则表达式的工作:
>>> import re>>> s = 'new Shopify.OptionSelectors("product-select",'>>> re.search('"ID":(\d+)',s).group(1)'185310341'总结
以上是内存溢出为你收集整理的python – Scrapy解析javascript全部内容,希望文章能够帮你解决python – Scrapy解析javascript所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)