CSDN极客头条Chrome插件开发

2016-02-17  本文已影响55人  周筱鲁

0x00 为何开发

刷微博刷到一条招募消息。
找不到工作的人就是闲

0x01 怎么做

看到有提到已经有书签的版本,这就好办,省得自己去找口啦!

然并卵

复制地址一看

javascript:window.location="http://geek.csdn.net/news/bookmarklet?u="+encodeURIComponent(document.location)+"&t="+encodeURIComponent(document.title)+""

好像很简洁,打开头条网址,找到右下角的发布,POST的完整实现应该是这样子的:

url: http://geek.csdn.net/service/news/add_edit
data: {
          'username': 'johnkivy',\\
          'title':'A Gentle Guide to Machine Learning',\\
          'url':'http://blog.monkeylearn.com/a-gentle-guide-to-machine-learning/',\\
          'description':'Nice',\\
          'tag':'Machine-Learning',\\
          'forum_id':'43'
      }

返回结果:

{"status":1,"error":"","data":{"id":38521},"is_god":false}

子社区的获取地址:

http://geek.csdn.net/service/news/forums

不带用户名参数巨慢(5s+),带上之后我的username=johnkivy之返回了12个数据。
返回结果

{"status":1,"error":"","data":[{"id":"47","name":"前端"},{"id":"1","name":"GEEK头条"},{"id":"8","name":"Rust"},{"id":"12","name":"Swift"},{"id":"14","name":"全栈工程师"},{"id":"17","name":"\/home"},{"id":"33","name":"PrestoDB"},{"id":"43","name":"人工智能"},{"id":"58","name":"安全"},{"id":"48","name":"Spark"},{"id":"49","name":"云计算"},{"id":"50","name":"潜水猿"},{"id":"53","name":"Container"},{"id":"55","name":"物联网"},{"id":"57","name":"SDN"},{"id":"61","name":"技术翻译"},{"id":"63","name":"虚拟现实"},{"id":"65","name":"Android开发者"},{"id":"66","name":"iOS开发"},{"id":"67","name":"Nodejs"},{"id":"68","name":"Python开发者"},{"id":"70","name":"AngularJS"},{"id":"71","name":"Grails\/Groovy"},{"id":"73","name":"Git教程"},{"id":"75","name":"Go"},{"id":"76","name":"CSDN前端"},{"id":"77","name":"CSDN PHPer"},{"id":"78","name":"C#极客区"},{"id":"79","name":".NET"}]}

目前我们大概需要的数据:

{
  "howtoadd": "http_request",
  "data": {
    "url": "http://geek.csdn.net/service/news/add_edit",
    "method": "POST",
    "loginrequired": "notsurenow",
    "data": {
      "username": "johnkivy",
      "title": "A Gentle Guide to Machine Learning",
      "url": "http://blog.monkeylearn.com/a-gentle-guide-to-machine-learning/",
      "description": "Nice",
      "tag": "Machine-Learning",
      "forum_id": {
        "form_ids": {
          "url": "http://geek.csdn.net/service/news/forums",
          "data": [{"id":"47","name":"前端"},...]
        }
      }
    }
  }
}

确定login required,方式很多可以用curl,Python ...,为表直观这里直接在浏览器中用一个HttpRequester的插件.

没有截图,得到的结果就是不用登陆,不排除在之后CSDN的Geek团队会加上,幸好有人工审核.不过这太不完善了,直接用别人用户名一交,比如我的那篇用yxy1992_123交过.

0x02 具体过程

简介为王,初步功能方向:

在Github上建个Repository.直接把代码鲁到master分支上去.

0x03 调试结果

0x04 发布与问题

上一篇下一篇

猜你喜欢

热点阅读