從mysql中取數(shù)據(jù) 自動發(fā)布新浪博客 視頻記錄開發(fā)全過程。
http://dl.dbank.com/c0v4nfrj54【下載不了的 使用下面的鏈接 (我怎么能下呢?
)】
代碼如下代碼 拿來是不能用的 你需要修改 數(shù)據(jù)庫鏈接字符串 還有表的名字 和字段
- import win.ui;
- import web.form;
- import math;
- import com;
- /*DSG{{*/
- var winform = win.form(parent=...; right=1148;text="AAuto Form";bottom=648 )
- winform.add(
- start_id={ bottom=47;right=566;left=537;top=18;font=LOGFONT( name="宋體";h=-12 );z=7;text="";edge=1;cls="edit" };
- static={ right=87;bottom=52;text="用戶名";left=19;top=23;font=LOGFONT( name="宋體";h=-12 );transparent=1;z=1;cls="static" };
- static2={ right=335;bottom=51;text="密碼";left=246;top=18;font=LOGFONT( name="宋體";h=-12 );transparent=1;z=2;cls="static" };
- password={ bottom=51;right=463;left=310;top=19;font=LOGFONT( name="宋體";h=-12 );z=6;text="password";edge=1;cls="edit" };
- end_id={ bottom=45;right=662;left=633;top=16;font=LOGFONT( name="宋體";h=-12 );z=8;text="";edge=1;cls="edit" };
- static4={ right=674;bottom=56;text="開始ID";left=577;top=18;font=LOGFONT( name="宋體";h=-12 );transparent=1;z=4;cls="static" };
- button={ bottom=47;right=742;left=692;top=13;font=LOGFONT( name="宋體";h=-12 );z=9;text="發(fā)送";cls="button" };
- sinaweb={ text="static5";bottom=510;right=1121;left=9;top=66;font=LOGFONT( name="宋體";h=-12 );transparent=1;z=10;cls="static" };
- username={ bottom=49;right=229;left=76;top=17;font=LOGFONT( name="宋體";h=-12 );z=5;text="testaau@sina.com";edge=1;cls="edit" };
- static3={ right=573;bottom=53;text="結(jié)束ID";left=488;top=20;font=LOGFONT( name="宋體";h=-12 );transparent=1;z=3;cls="static" }
- )
- /*}}*/
- var wb = web.form(winform.sinaweb)
- winform.button.oncommand = function(id,event){
-
- var username = winform.username.text;
- var password = winform.password.text;
- if (username == '' || password == '') {
- win.msgboxTest("請輸入用戶名和密碼","錯誤消息")
- return;
- }
-
-
- var s_id = winform.start_id.text
- var e_id = winform.end_id.text
-
- if (s_id == '' || e_id == '') {
-
- win.msgboxTest("請輸入開始 id 結(jié)束id ","標題")
- return;
- }
-
-
- wb.go("http://control.blog.sina.com.cn/admin/article/article_add.php")
- wb.wait("")
-
- check_is_login()
-
-
- s_id = tonumber(s_id)
- e_id = tonumber(e_id)
-
- for(i=s_id; e_id ;1) {
- var blog_info = get_blog_from_db(i)
- send_blog(blog_info.title, blog_info.content, "it 計算機語言")
- wb.location = "http://control.blog.sina.com.cn/admin/article/article_add.php"
- }
-
-
-
- }
- delay_click = function (ele) {
- var temp_time = math.random(200, 500)
- win.delay(temp_time)
- ele.click()
- ele.fireEvent("onfocus")
- }
- check_is_login = function() {
- var username = winform.username.text;
- var password = winform.password.text;
- if (string.find(wb.location, 'login.sina.com.cn')) {
- login_sina(username, password)
- } else {
- logout_sina()
- login_sina(username, password)
- }
- }
- login_sina = function(blog_username, blog_password) {
- win.delay(3000)
- wb.getEle("username").value = blog_username;
- wb.getEle("password").value = blog_password;
- var doc = wb.getDoc()
- var ele = doc.all(56)
- delay_click(ele)
- }
- logout_sina = function() {
- win.delay(3000)
- var doc = wb.getDoc()
- var ele = doc.all(35)
- ele.click()
- }
- send_blog = function(title, content, tag) {
- win.delay(3000)
- //title
- wb.getEle("articleTitle").value = title
- var doc = wb.getDoc(0)
- doc.all(5).innerHTML = content
- wb.getEle("articleTagInput").value = tag
- wb.waitEle("sort_id_20_113").click()
-
- var send_button = wb.getEle("articlePostBtn")
- delay_click(send_button)
-
- win.delay(65000)
- }
- get_blog_from_db = function(id) {
- var blog_info = {title: ''; content : ''}
- conn = com.CreateObject("ADODB.Connection")
- conn.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=wordpressdb;Uid=root;Pwd=password;Connect Timeout=1000;"
- conn.Open()
- rs = com.CreateObject("ADODB.RecordSet")
- rs.open(" select * from wp_posts where id = " + id, conn)
-
- while(! rs.eof){
- blog_info.title = rs ('post_title').value
- blog_info.content = rs ('post_content').value
- rs.movenext()
- }
- rs.close()
- conn.close()
- return blog_info
- }
- winform.show()
- win.loopMessage();
- return winform;
復(fù)制代碼
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。