Logo

Logo

python爬虫自动采集并上传更新网站 requests wordpress_xmlrpc wordpress实战

Pastore Antonio
Pastore Antonio 2020年09月08日
389 阅读 0 评论 约 1479 字 阅读约 3 分钟

爬虫用的 bs4+requests

上传用的  wordpress_xmlrpc

#coded by 伊玛目的门徒
#coding=utf-8
from wordpress_xmlrpc import Client, WordPressPost
from wordpress_xmlrpc.methods.posts import GetPosts, NewPost
from wordpress_xmlrpc.methods.users import GetUserInfo
import time
import requests
from bs4 import BeautifulSoup

header={'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.XXXX.XXX Safari/537.36'}

def getcontent():
    try:
        html=requests.get('https://futures.hexun.com/2019-12-17/199706366.html',headers=header)

        html.encoding='gbk'

        Soup = BeautifulSoup(html.text, "lxml")

        con=Soup.select('div.art_contextBox p')

        cont=''
        for y in con:
            #print (type(str(y)))
            cont=cont+str(y)

        print (cont)

        return (cont)

    except:
        pass


def wpsend(content):
    wp = Client('http://www.lianhanghao.xyz/xmlrpc.php', '***' '***')

    print (content)
    post = WordPressPost()
    post.title = '实例演示'
    post.content = " ''' "+ content +" ''' "

    post.post_status = 'publish'
    post.terms_names = {
       'post_tag': ['test'],
      'category': [ 'Tests']
    }
    wp.call(NewPost(post))
    localtime = time.localtime(time.time())
    print ('文档已上传 {}'.format(time.strftime("%Y-%m-%d %H:%M:%S",localtime)))



wpsend(getcontent())

网站在 http://www.lianhanghao.xyz/tests/317362

演示视频: https://www.bilibili.com/video/av80056985/

查看完整代码

橙子主题打折出售

其实我不卖,主要是这里是放广告的,所以就放了一个
毕竟主题都没做完,卖了也是坑.

购买它
部分文章可能存在转载,如果涉及到侵权,请联系删除文章。

留言板

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

6 - 1 = ?

探索AIGC相关的精彩内容,共 15 篇文章

Azure AI 服务之语音识别

简介 Azure AI 服务中的语音识别 API 是微软提供的一项先进技术,旨在帮助开发者轻松实现语 ... python爬虫自动采集并上传更新网站 requests wordpress_xmlrpc wordpress实战

2026-02-17 · Xzavier Aaron
MCP | 一文详解什么是 MCP以及 MCP 可以做什么

一、什么是 MCP MCP(Model Context Protocol)是一个专为大型语言模型(L ... python爬虫自动采集并上传更新网站 requests wordpress_xmlrpc wordpress实战

2026-02-14 · Shen, Luke
你的工作流程,值得一个“全自动数字分身”:录制、截图、成文,一气呵成

一、一句话认识 TestFlow Recorder 在数字化工作环境中,如何准确记录操作步骤并生成清 ... python爬虫自动采集并上传更新网站 requests wordpress_xmlrpc wordpress实战

2026-02-14 · Xzavier Aaron
Flowise 前端框架配置指南

用户需求 问题:有没有适合配置 Flowise 的前端框架? 目标:寻找类似 Open WebUI ... python爬虫自动采集并上传更新网站 requests wordpress_xmlrpc wordpress实战

2026-02-14 · Xzavier Aaron