weui js 读取PHP,微信公众号开发weui使用心得

微信公众号开发weui使用心得,避免少犯错!

特别注意:

如果使用 jquery,则 jquery.js 一定要放在

的最后面,否则 weui 不起作用。

引用部分 weui

只需要加载 weui.css 即可{% load staticfiles %}

引用 weui 整个例子框架head link css

WeUI

{% load staticfiles %}

body 最后写上 js

weui 结构

注意事项:

如果 page 的上面不写 id="tpl_home" 就会报错

报错如下:Uncaught TypeError: Cannot set property 'url' of undefined

at setPageManager (example.js:264)

at init (example.js:289)

at example.js:296

at HTMLDocument. (zepto.min.js:1)

下面是在 chromium 中报错图:

202c6fd928d91419451ef9b196933a45.png

来自简书swotpp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WebMagic 是一款非常好用的 Java 爬虫框架,可以用来爬取各种网站。对于爬取微信公众号,可以使用 WebMagic 结合公众号的历史文章链接来进行爬取。下面是一个简单的爬取微信公众号文章的示例代码: ```java import us.codecraft.webmagic.processor.PageProcessor; import us.codecraft.webmagic.Site; import us.codecraft.webmagic.Spider; import us.codecraft.webmagic.selector.Html; import us.codecraft.webmagic.selector.Selectable; import java.util.List; public class WeChatPublicAccountPageProcessor implements PageProcessor { private Site site = Site.me().setRetryTimes(3).setSleepTime(1000); public Site getSite() { return site; } public void process(Page page) { Html html = page.getHtml(); String title = html.xpath("//title/text()").get(); List<Selectable> articleNodes = html.xpath("//div[@class='weui_media_bd']/h4/a") .nodes(); for (Selectable node : articleNodes) { String articleTitle = node.xpath("/a/text()").get(); String articleUrl = node.xpath("/a/@href").get(); // 把文章链接放到待爬取队列中 page.addTargetRequest(articleUrl); } // 如果是文章页面,则解析文章内容 if (page.getUrl().regex("https://mp.weixin.qq.com/s").match()) { String content = html.xpath("//div[@class='rich_media_content']") .get(); // 把文章内容存储到数据库中或者进行其他处理 // ... } } public static void main(String[] args) { Spider.create(new WeChatPublicAccountPageProcessor()) .addUrl("https://mp.weixin.qq.com/profile?{account_id}") .run(); } } ``` 代码中,我们使用了 WebMagic 的 `PageProcessor` 接口来处理页面,通过 `addUrl()` 方法来添加待爬取的微信公众号链接,然后在 `process()` 方法中解析历史文章链接并添加到待爬取队列中,如果是文章页面,则解析文章内容并进行其他处理。需要注意的是,需要替换花括号中的 `{account_id}` 为对应的公众号ID。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值