python scrapy 表单post rest api接口返回json写wordpress
2022/1/5 22:34:28
本文主要是介绍python scrapy 表单post rest api接口返回json写wordpress,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import scrapy import json from urllib.parse import urlencode from scrapy.crawler import CrawlerProcess from scrapy import Spider, FormRequest from wordpress_xmlrpc import Client, WordPressPost from wordpress_xmlrpc.methods.posts import NewPost id = 'username' password = 'pwd' publish_url = 'http://wordpress.url/xmlrpc.php' source_url = 'http://gubatopic.eastmoney.com/interface/GetData.aspx' post_data ={"param": "ps%3D7%26p%3D1%26type%3D0","path":"newtopic%2Fapi%2FTopic%2FHomePageListRead","env":"2"} class EmSpider(Spider): name = "em" def start_requests(self): yield FormRequest(source_url, formdata=post_data) def parse(self,response): for item in json.loads(response.text)['re']: print(item['nickname']+' ,'+str(item['htid'])) wp = Client(publish_url, id, password) post = WordPressPost() post.post_status = 'publish' post.title = item['nickname'] post.content = str(item['htid']) #post.excerpt = '这里是摘抄样式示例' post.terms_names = { "post_tag": ['Python'], "category": ['Python'] } wp.call(NewPost(post))
这篇关于python scrapy 表单post rest api接口返回json写wordpress的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-25Vue3学习:从入门到初步掌握
- 2024-12-25Vue3入门:新手必读的简单教程
- 2024-12-23【JS逆向百例】爱疯官网登录逆向分析
- 2024-12-21Vue3教程:新手入门到实践应用
- 2024-12-21VueRouter4教程:从入门到实践
- 2024-12-20Vue3项目实战:从入门到上手
- 2024-12-20Vue3项目实战:新手入门教程
- 2024-12-20VueRouter4项目实战:新手入门教程
- 2024-12-20如何实现JDBC和jsp的关系?-icode9专业技术文章分享
- 2024-12-20Vue项目中实现TagsView标签栏导航的简单教程