js  修改  iframe

it=document.getElementById('ueditor_0').contentWindow.document.getElementsByTagName("body")[0];

it.innerHTML='<li ><img src="https://www.baidu.com/img/baidu_jgylogo3.gif" alt="qq_383" title="qq_3503"></li><li >qq_3203</li><li >2017年04月13日 10:02</li><li ><span>3074</span></li>'

  1. from selenium import webdriver
  2. from time import sleep
  3. import time
  4. from selenium.webdriver.common.keys import Keys
  5. import os
  6.  
  7. import requests
  8. import time
  9. import threading
  10. import logging
  11. import random
  12.  
  13. start_time = time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time()))
  14. os_sep = os.sep
  15. this_file_abspath, this_file_name = os.path.dirname(os.path.abspath(__file__)), os.path.abspath(__file__).split(os_sep)[
  16. -1]
  17. logf = this_file_name + '.log'
  18. try:
  19. logging.basicConfig(level=logging.INFO,
  20. format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s[thread:%(thread)d][process:%(process)d]',
  21. datefmt='%a, %d %b %Y %H:%M:%S',
  22. filename=logf,
  23. filemode='a')
  24. except Exception as e:
  25. s = '%s%s%s' % ('logging.basicConfig EXCEPTION ', time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())), e)
  26. with open(logf, 'a') as fo:
  27. fo.write(s)
  28. print(s)
  29. os._exit(4002)
  30.  
  31. logging.info('START')
  32.  
  33. img_url = 'https://s3.pstatp.com/toutiao/static/img/logo.201f80d.png'
  34. img_dir = 'C:\\Users\\sas\\PycharmProjects\\py_win_to_unix\\crontab_chk_url\\personas\\trunk\\plugins\\spider\\dl_img_tmp\\'
  35.  
  36. def spider_webimg_dl_return_local_img_path(img_dir, img_url, local_default='default.DONOT_REMOVE.png'):
  37. r = '%s%s' % (img_dir, local_default)
  38. try:
  39. bytes = requests.get(img_url)._content
  40. r = '%s%s%s%s%s' % (
  41. img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
  42. img_url.replace('/', '_xl_').replace(':', '_fxl_').replace('?', '_fxlquestion_').replace('=',
  43. '_fxlequal_').replace(
  44. '&', '_fxland_'), '.png')
  45. if bytes != 0:
  46. with open(r, 'wb')as f:
  47. f.write(bytes)
  48. except Exception as e:
  49. print(e)
  50. return r
  51.  
  52. import pymysql
  53.  
  54. h, pt, u, p, db = '192.168.2.210', 3306, 'root', 'joke_', 'star_media_helper'
  55.  
  56. def mysql_fetch(sql, res_type='tuple'):
  57. global h, pt, u, p, db
  58. try:
  59. conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8')
  60. except Exception as e:
  61. print(e)
  62. return ()
  63. if res_type == 'dic':
  64. cursor = conn.cursor(pymysql.cursors.DictCursor)
  65. else:
  66.  
  67. cursor = conn.cursor()
  68. cursor.execute(sql)
  69. conn.commit()
  70. cursor.close()
  71. conn.close()
  72. return cursor.fetchall()
  73.  
  74. def mysql_write(sql):
  75. global h, pt, u, p, db
  76. try:
  77. conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8')
  78. except Exception as e:
  79. print(e)
  80. return 1
  81. cursor = conn.cursor()
  82. cursor.execute(sql)
  83. conn.commit()
  84. cursor.close()
  85. conn.close()
  86. return 0
  87.  
  88. import random
  89.  
  90. while True:
  91. logging.info('LOOP----')
  92. sql = 'SELECT username,password,toutiaoid FROM joke__star_helper_namepwd WHERE status=1 AND category=1 AND id>236 AND NOT (toutiaoid IS NULL OR toutiaoid="" )'
  93. sql = 'SELECT username,password,toutiaoid FROM joke__star_helper_namepwd WHERE status=1 AND category=1 AND id=7856582 AND NOT (toutiaoid IS NULL OR toutiaoid="" )'
  94. res = mysql_fetch(sql)
  95. ac_l = [{'u': i[0], 'p': i[1], 'toutiao_uid': i[2]} for i in res]
  96. for ac in ac_l:
  97. myid, mypwd, toutiao_uid = ac['u'], ac['p'], ac['toutiao_uid']
  98. # 发布限制条件逻辑
  99. sql = "SELECT * FROM joke__star_helper_relation_wukong_question WHERE INSTR(CONCAT(',',id_toutiao_uid_list,','),CONCAT(',','{}',',')) AND time_effective<={} ORDER BY id DESC; ".format(
  100. toutiao_uid, int(time.time()));
  101. sql = "SELECT * FROM joke__helper_article_publish WHERE INSTR(CONCAT(',',id_toutiao_uid_list,','),CONCAT(',','{}',',')) AND time_effective<={} ORDER BY id DESC; ".format(
  102. toutiao_uid, int(time.time()));
  103. print(sql)
  104. logging.info(sql)
  105. res_content = mysql_fetch(sql, 'dic')
  106. if len(res_content) == 0:
  107. continue
  108. id_article_list = [i['id_article_list'] for i in res_content]
  109.  
  110. sql = 'SELECT * FROM joke__helper_article WHERE id IN ({}) AND id NOT IN (SELECT article_id FROM joke__helper_article_publish_result WHERE 1 AND toutiao_uid="{}" ) LIMIT 2; '.format(
  111. ','.join([i['id_article_list'] for i in res_content]), toutiao_uid)
  112. # sql = 'SELECT * FROM joke__star_helper_wukong_question WHERE id NOT IN (SELECT toutiao_uid FROM joke__star_helper_toutiaouser_wukong_question) LIMIT 1'
  113. logging.info(sql)
  114. res_content = mysql_fetch(sql, 'dic')
  115. if len(res_content) == 0:
  116. continue
  117.  
  118. browser = webdriver.Chrome()
  119. f_url_l = ['https://www.toutiao.com/group/1589657566362638/',
  120. 'https://www.wukong.com/question/6388670742287876353/',
  121. 'https://www.wukong.com/tag/6215497898671475202/']
  122. f_url_l += ['https://www.wukong.com/question/6512777037948649741/',
  123. 'https://www.wukong.com/question/6469247721038414093/',
  124. 'https://www.wukong.com/question/6481502080249889037/']
  125. # f_url_l = []
  126. f_url_l = ['https://www.toutiao.com/a6514526304476332552/', 'https://www.toutiao.com/a6514661446876398088/',
  127. 'https://www.toutiao.com/a6514778729951003150/']
  128. f_url_l += ['https://www.toutiao.com/a6514216125151052291/', 'https://www.toutiao.com/a6512315164463727111/',
  129. 'https://www.toutiao.com/a6513334304318161411/']
  130. f_url_l_a = f_url_l[int(time.time()) % len(f_url_l)]
  131. # browser.get(random.choice(f_url_l))
  132. browser.get(f_url_l_a)
  133. time.sleep(random.randint(10, 20))
  134.  
  135. js = 'window.location.href="https://sso.toutiao.com/login/";'
  136. js = 'window.location.href="https://sso.toutiao.com/login/?service=https://mp.toutiao.com/sso_confirm/?redirect_url=/";'
  137. browser.execute_script(js)
  138. time.sleep(random.randint(10, 20))
  139.  
  140. # js = 'window.location.href="https://sso.toutiao.com/login/?service=https%3A%2F%2Fwww.wukong.com%2Fwenda%2Fwelcome%2F#type=0";'
  141. browser.execute_script(js)
  142.  
  143. ac_type = 'qq'
  144. if ac_type == 'qq':
  145. myid, mypwd = ac['u'], ac['p']
  146. xp = '/html/body/div/div/div[2]/div/div/div/ul/li[3]'
  147. browser.find_element_by_xpath(xp).click()
  148. time.sleep(10)
  149. js = '%s%s%s' % ('document.getElementById("u").value="', myid, '"')
  150. browser.execute_script(js)
  151. js = '%s%s%s' % ('document.getElementById("p").value="', mypwd, '"')
  152. browser.execute_script(js)
  153. time.sleep(random.randint(5, 15))
  154. xp_newpage = '//*[@id="go"]'
  155. browser.find_element_by_xpath(xp_newpage).click()
  156. time.sleep(random.randint(10, 20))
  157. elif ac_type == 'mail_qq':
  158. continue
  159.  
  160. time.sleep(5)
  161.  
  162. browser.refresh()
  163. js = 'window.location.href="https://www.toutiao.com/";'
  164. browser.execute_script(js)
  165. browser.refresh()
  166.  
  167. time.sleep(6)
  168.  
  169. js = 'window.location.href="https://www.wukong.com/";'
  170. js = 'window.location.href="https://mp.toutiao.com/profile_v2/publish/";'
  171. js = 'window.location.href="https://mp.toutiao.com/profile_v3/graphic/publish";'
  172. browser.execute_script(js)
  173.  
  174. time.sleep(6)
  175.  
  176. # title
  177. js = '%s%s%s' % ('document.getElementById("title").value="', '林志玲捐款记录被翻出 单笔高达千万', '"')
  178. js = 'document.getElementById("title").value="{}"'.format('林志玲捐款记录被翻出 单笔高达千万')
  179.  
  180. browser.execute_script(js)
  181. time.sleep(2)
  182.  
  183. fhtml, dbhtml_str = 'toutaio.db.html', ''
  184. with open(fhtml, 'r', encoding='utf-8') as fr:
  185. for hi in fr:
  186. dbhtml_str = '{}{}'.format(dbhtml_str, hi.replace('\n', ''))
  187.  
  188. db_html = dbhtml_str
  189. # db_html = '<li ><img src="https://www.baidu.com/img/baidu_jgylogo3.gif" alt="qq_383" title="qq_3503"></li><li >qq_3203</li><li >2017年04月13日 10:02</li><li ><span>3074</span></li>'
  190. js = 'it=document.getElementById("ueditor_0").contentWindow.document.getElementsByTagName("body")[0];it.innerHTML="{}"'.format(
  191. db_html)
  192. browser.execute_script(js)
  193. time.sleep(2)
  194.  
  195. xp = '//*[@id="graphic"]/div/div/div[2]/div[3]/div[2]/div[1]'
  196. xp = '//*[@id="graphic"]/div/div/div[2]/div[3]/div[2]/div[1]'
  197. browser.find_element_by_xpath(xp).click()
  198. dd = 9
  199. # js = 'document.getElementsByClassName("ask")[0].click();'
  200. # browser.execute_script(js)
  201. # time.sleep(12)
  202.  
  203. # time.sleep(random.randint(10, 20))
  204. # # 需要键盘事件 反爬虫
  205. # tmp_target = browser.find_element_by_class_name('input-box').find_element_by_tag_name('input')
  206. # tmp_target.send_keys(Keys.SPACE)
  207. # tmp_target.send_keys(Keys.CONTROL, 'a')
  208. # tmp_target.send_keys(Keys.CONTROL, 'x')
  209. # tmp_target.send_keys(Keys.CONTROL, 'v')
  210. # tmp_target.send_keys(Keys.BACK_SPACE)
  211. # time.sleep(random.randint(10, 20))
  212.  
  213. # res_content = []
  214. for i in res_content[0:1]:
  215. dbid, content, img_list = i['id'], i['content'], i['img_list']
  216.  
  217. tmp_l = ['口红', '指甲油', '护发素', '沐浴露', '洗手液', '洗发水', '牙膏']
  218. tmp_l_1 = ['老人', '小孩', '白领', '前台妹子', '行政妹子', '大学生', '高中生']
  219. tmp_l_2 = ['类型', '特质', '种类', '价位', '原材料', '主要成分', '价格']
  220.  
  221. s = '{}{}{}{}{}{}{}'.format(str(random.randint(1, 12)), '月份,', random.choice(tmp_l_1), '适合使用什么',
  222. random.choice(tmp_l_2), '的', random.choice(tmp_l))
  223. js = 'document.getElementsByClassName("input-box")[0].childNodes[0].value="{}";'.format(s)
  224. browser.execute_script(js)
  225. time.sleep(12)
  226. #
  227. # tmp_target.send_keys(Keys.SPACE)
  228.  
  229. js = 'document.getElementsByClassName("step-btn next")[0].click();'
  230. browser.execute_script(js)
  231.  
  232. # step-btn submit
  233.  
  234. js = 'document.getElementsByClassName("step-btn submit")[0].click();'
  235. browser.execute_script(js)
  236. time.sleep(12)
  237.  
  238. #
  239. js = 'window.location.href="https://www.wukong.com/user/?uid={}&type=1";'.format(toutiao_uid)
  240. browser.execute_script(js)
  241. time.sleep(12)
  242. res_url = browser.find_element_by_class_name('question-title').find_elements_by_tag_name('a')[
  243. 0].get_attribute('href')
  244.  
  245. # print(i)
  246. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/div/div/div/textarea'
  247. # try:
  248. # browser.find_element_by_xpath(xp_newpage)
  249. # except Exception as e:
  250. # print(e)
  251. # break
  252. # browser.find_element_by_xpath(xp_newpage).click()
  253. # words = content
  254. # # Message: SyntaxError: unterminated string literal
  255. # mytxt = words.replace('\n', ' ').replace('\r', ' ').replace('\\br', ' ').replace('"', '“').replace("'", '‘')
  256. # # Message: SyntaxError: missing ; before statement
  257. # mytxt = mytxt.replace("'", '‘')
  258. # # 2000 头条
  259. # mytxt = mytxt[0:2000]
  260. # mytxt = '好消息' if len(mytxt.replace(' ', '')) == 0 else mytxt
  261. #
  262. # # 需要键盘事件 反爬虫
  263. # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.SPACE)
  264. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.CONTROL, 'a')
  265. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.CONTROL, 'x')
  266. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.CONTROL, 'v')
  267. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.BACK_SPACE)
  268. # time.sleep(random.randint(2, 5))
  269. #
  270. # try:
  271. # # js = '%s%s%s' % ('document.getElementsByTagName("textarea")[0].value="', '', '"')
  272. # # browser.execute_script(js)
  273. # js = '%s%s%s' % ('document.getElementsByTagName("textarea")[0].value="', mytxt, '"')
  274. # browser.execute_script(js)
  275. # time.sleep(3)
  276. # except Exception as jse:
  277. # print('.getElementsByTagName("textarea")--log-', jse)
  278. # continue
  279. #
  280. # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.SPACE)
  281. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/div/div/div/div[1]/div[1]/span[1]/span'
  282. # browser.find_element_by_xpath(xp_newpage).click()
  283. # time.sleep(3)
  284. # try:
  285. # upload = browser.find_element_by_id('fileElem')
  286. #
  287. # logs_img = ''
  288. # img_url_list = img_list.split(',')
  289. #
  290. # for imgid in img_url_list:
  291. # img_url = 'http://192.168.2.212:83/file/get?type=star_helper&id=199'.replace('199', str(imgid))
  292. # local_img_path = spider_webimg_dl_return_local_img_path(img_dir, img_url,
  293. # local_default='default.DONOT_REMOVE.png')
  294. # print(local_img_path)
  295. # time.sleep(random.randint(2, 4))
  296. # logs_img += img_url
  297. # logs_img += local_img_path
  298. # upload.send_keys(local_img_path)
  299. # time.sleep(random.randint(3, 7))
  300. # except Exception as ee:
  301. # img_url_default = ''
  302. # img_url = img_url_default
  303. # local_img_path = spider_webimg_dl_return_local_img_path(img_dir, img_url,
  304. # local_default='default.DONOT_REMOVE.png')
  305. # sleep(2)
  306. # logs_img += img_url
  307. # logs_img += local_img_path
  308. # # upload.send_keys(local_img_path)
  309. # logging.exception(ee)
  310. #
  311. # try:
  312. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/ul'
  313. # browser.find_element_by_xpath(xp_newpage).click()
  314. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/div/div/div/div[1]/div[2]/a'
  315. # browser.find_element_by_xpath(xp_newpage).click()
  316. #
  317. # time.sleep(random.randint(8, 20))
  318. # js = 'document.getElementsByClassName("ugc-mode-content")[0].getElementsByTagName("a")[0].target="_self"'
  319. # browser.execute_script(js)
  320. #
  321. # time.sleep(random.randint(2, 5))
  322. # xp_newpage = '/html/body/div/div[2]/div[2]/div[2]/ul/li[1]/div/div[2]/div/div[2]/a'
  323. # browser.find_element_by_xpath(xp_newpage).click()
  324. # time.sleep(random.randint(3, 6))
  325. # url_curr = browser.current_url
  326. #
  327. # with open('toutiao_success.log', 'a', encoding='utf-8') as f:
  328. # logs = '%s%s%s%s%s\n' % (
  329. # time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())), ac_type, myid[0:4], mytxt,
  330. # logs_img)
  331. # print(logs)
  332. # f.write(logs)
  333.  
  334. sql = 'INSERT INTO joke__helper_article_publish_result (article_id,article_url,time_script,toutiao_uid) VALUE("%s","%s","%s","%s");' % (
  335. dbid, res_url, int(time.time()), toutiao_uid)
  336. mysql_write(sql)
  337. print(sql)
  338. time.sleep(random.randint(20, 30))
  339. js = 'window.location.href="https://www.wukong.com/"'
  340. js = 'window.location.href="https://www.toutiao.com/"'
  341. browser.execute_script(js)
  342. # except Exception as e_url_jump:
  343. # print('e_url_jump', e_url_jump)
  344. try:
  345. browser.quit()
  346. except Exception as e1:
  347. print(e1)
  348. logging.exception(e1)
  349.  
  350. time.sleep(random.randint(120, 300))
  1. xp_newpage = '//*[@id="title"]'
  2. mytxt = '林志玲捐款记录被翻出 单笔高达千万'
  3. browser.find_element_by_xpath(xp_newpage).send_keys(Keys.SPACE)
  4. browser.find_element_by_xpath(xp_newpage).send_keys(mytxt)

  

  1. <div class='article' id='artibody'>
  2. <div class='img_wrapper'>
  3. <img alt='林志玲' src='http://n.sinaimg.cn/ent/transform/703/w253h450/20180416/77p2-fzcyxmv1344655.jpg'>
  4. <span class='img_descr'>林志玲</span>
  5. </div>
  6. <div class='img_wrapper'>
  7. <img alt='林志玲捐款记录' src='http://n.sinaimg.cn/ent/transform/250/w600h450/20180416/CVWm-fzcyxmv1342897.jpg'>
  8. <span class='img_descr'>林志玲捐款记录</span>
  9. </div>
  10. <div class='img_wrapper'>
  11. <img alt='林志玲捐款记录' src='http://n.sinaimg.cn/ent/transform/250/w600h450/20180416/hXMn-fzcyxmv1342914.jpg'>
  12. <span class='img_descr'>林志玲捐款记录</span>
  13. </div> <!--video-list-->
  14. <div class='video-2017' id='videoList0'></div>
  15.  
  16. <!--/video-list-->
  17. <p>  新浪娱乐讯 据台湾媒体报道,林志玲
  18. 自出道以来,热心公益,甚至创立了自己的基金会,每年固定发行公益年历。近日明星从事公益的话题发烧,她也被网友挖出,几乎每个月都在转帐捐款,且其中一笔高达1000万人民币,更让网友惊呼连连。
  19. </p>
  20. <div id='ad_44124' class='otherContent_01'
  21. style='display: block; margin: 10px 20px 10px 0px; float: left; overflow: hidden; clear: both; padding: 4px; width: 300px; height: 250px;'>
  22.  
  23. </div>
  24. <p>
  25.   林志玲被网友翻出,2016年至2018年间的捐款纪录,几乎每个月都有记录,且最低都是人民币万元起跳,其中甚至有一笔高达1000万人民币,捐款项目是“筑巢行动”,不少人看到明细,都惊讶表示,原来志玲姐姐私下默默捐了这么多善款,还有人笑称:“她是不是拿着手机,无聊就转帐的那种人?”、“真的人美心也美”、“太圈粉了”、“志玲姐姐真的太低调了”。</p>
  26. <p>
  27.   43岁的林志玲1998年出道,从伸展台转战影视圈,尚未出名前就热心公益,更在2011年,主动以个人名义,成立“志玲姐姐慈善基金会”。她也固定每年拍摄公益写真年历,所得全数捐给儿福机构,或是帮助弱势孩童急难救助等,多年从不间断,且义卖期间,她从不公开做宣传,低调行善,受到不少人赞赏。</p>
  28. <p>
  29.   林志玲2016年受访曾透露,投入公益的契机,是因为身边罹癌友人的一句话,才让她下定决心。当时这位好友问她:“你希望离开后,怎样被大家记得?”她想了一想,认为既然是公众人物,就应该让大家记得自己微笑的样子,要用这样的身分,做些有影响力的事,从此将公益当做自我赋予的使命,一做就是好多年。ETtoday/文</p>
  30. <p class='article-editor'>(责编:kita)</p>
  31. <div style='font-size: 0px; height: 0px; clear: both;'></div>
  32.  
  33. </div>
  34. <!-- 非定向300*250按钮 end -->
  35. </div>

  

  1. from selenium import webdriver
  2. from time import sleep
  3. import time
  4. from selenium.webdriver.common.keys import Keys
  5. import os
  6.  
  7. import requests
  8. import time
  9. import threading
  10. import logging
  11. import random
  12.  
  13. start_time = time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time()))
  14. os_sep = os.sep
  15. this_file_abspath, this_file_name = os.path.dirname(os.path.abspath(__file__)), os.path.abspath(__file__).split(os_sep)[
  16. -1]
  17. logf = this_file_name + '.log'
  18. try:
  19. logging.basicConfig(level=logging.INFO,
  20. format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s[thread:%(thread)d][process:%(process)d]',
  21. datefmt='%a, %d %b %Y %H:%M:%S',
  22. filename=logf,
  23. filemode='a')
  24. except Exception as e:
  25. s = '%s%s%s' % ('logging.basicConfig EXCEPTION ', time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())), e)
  26. with open(logf, 'a') as fo:
  27. fo.write(s)
  28. print(s)
  29. os._exit(4002)
  30.  
  31. logging.info('START')
  32.  
  33. img_url = 'https://s3.pstatp.com/toutiao/static/img/logo.201f80d.png'
  34. img_dir = 'C:\\Users\\sas\\PycharmProjects\\py_win_to_unix\\crontab_chk_url\\personas\\trunk\\plugins\\spider\\dl_img_tmp\\'
  35.  
  36. def spider_webimg_dl_return_local_img_path(img_dir, img_url, local_default='default.DONOT_REMOVE.png'):
  37. r = '%s%s' % (img_dir, local_default)
  38. try:
  39. bytes = requests.get(img_url)._content
  40. r = '%s%s%s%s%s' % (
  41. img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
  42. img_url.replace('/', '_xl_').replace(':', '_fxl_').replace('?', '_fxlquestion_').replace('=',
  43. '_fxlequal_').replace(
  44. '&', '_fxland_'), '.png')
  45. if bytes != 0:
  46. with open(r, 'wb')as f:
  47. f.write(bytes)
  48. except Exception as e:
  49. print(e)
  50. return r
  51.  
  52. import pymysql
  53.  
  54. h, pt, u, p, db = '192.168.2.210', 3306, 'root', 'joke', 'star_media_joke'
  55.  
  56. def mysql_fetch(sql, res_type='tuple'):
  57. global h, pt, u, p, db
  58. try:
  59. conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8')
  60. except Exception as e:
  61. print(e)
  62. return ()
  63. if res_type == 'dic':
  64. cursor = conn.cursor(pymysql.cursors.DictCursor)
  65. else:
  66.  
  67. cursor = conn.cursor()
  68. cursor.execute(sql)
  69. conn.commit()
  70. cursor.close()
  71. conn.close()
  72. return cursor.fetchall()
  73.  
  74. def mysql_write(sql):
  75. global h, pt, u, p, db
  76. try:
  77. conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8')
  78. except Exception as e:
  79. print(e)
  80. return 1
  81. cursor = conn.cursor()
  82. cursor.execute(sql)
  83. conn.commit()
  84. cursor.close()
  85. conn.close()
  86. return 0
  87.  
  88. import random
  89.  
  90. while True:
  91. logging.info('LOOP----')
  92. sql = 'SELECT username,password,toutiaoid FROM joke_star_joke_joke_namepwd WHERE status=1 AND category=1 AND id>236 AND NOT (toutiaoid IS NULL OR toutiaoid="" )'
  93. sql = 'SELECT username,password,toutiaoid FROM joke_star_joke_namepwd WHERE status=1 AND category=1 AND id=7856582 AND NOT (toutiaoid IS NULL OR toutiaoid="" )'
  94. res = mysql_fetch(sql)
  95. ac_l = [{'u': i[0], 'p': i[1], 'toutiao_uid': i[2]} for i in res]
  96. for ac in ac_l:
  97. myid, mypwd, toutiao_uid = ac['u'], ac['p'], ac['toutiao_uid']
  98. # 发布限制条件逻辑
  99. sql = "SELECT * FROM joke_star_joke_relation_wukong_question WHERE INSTR(CONCAT(',',id_toutiao_uid_list,','),CONCAT(',','{}',',')) AND time_effective<={} ORDER BY id DESC; ".format(
  100. toutiao_uid, int(time.time()));
  101. sql = "SELECT * FROM joke_joke_article_publish WHERE INSTR(CONCAT(',',id_toutiao_uid_list,','),CONCAT(',','{}',',')) AND time_effective<={} ORDER BY id DESC; ".format(
  102. toutiao_uid, int(time.time()));
  103. print(sql)
  104. logging.info(sql)
  105. res_content = mysql_fetch(sql, 'dic')
  106. if len(res_content) == 0:
  107. continue
  108. id_article_list = [i['id_article_list'] for i in res_content]
  109.  
  110. sql = 'SELECT * FROM joke_joke_article WHERE id IN ({}) AND id NOT IN (SELECT article_id FROM joke_joke_article_publish_result WHERE 1 AND toutiao_uid="{}" ) LIMIT 2; '.format(
  111. ','.join([i['id_article_list'] for i in res_content]), toutiao_uid)
  112. # sql = 'SELECT * FROM joke_star_joke_wukong_question WHERE id NOT IN (SELECT toutiao_uid FROM joke_star_joke_toutiaouser_wukong_question) LIMIT 1'
  113. logging.info(sql)
  114. res_content = mysql_fetch(sql, 'dic')
  115. if len(res_content) == 0:
  116. continue
  117.  
  118. browser = webdriver.Chrome()
  119. f_url_l = ['https://www.toutiao.com/group/1589657566362638/',
  120. 'https://www.wukong.com/question/6388670742287876353/',
  121. 'https://www.wukong.com/tag/6215497898671475202/']
  122. f_url_l += ['https://www.wukong.com/question/6512777037948649741/',
  123. 'https://www.wukong.com/question/6469247721038414093/',
  124. 'https://www.wukong.com/question/6481502080249889037/']
  125. # f_url_l = []
  126. f_url_l = ['https://www.toutiao.com/a6514526304476332552/', 'https://www.toutiao.com/a6514778729951003150/']
  127. f_url_l += ['https://www.toutiao.com/a6514216125151052291/', 'https://www.toutiao.com/a6512315164463727111/',
  128. 'https://www.toutiao.com/a6513334304318161411/']
  129. f_url_l_a = f_url_l[int(time.time()) % len(f_url_l)]
  130. # browser.get(random.choice(f_url_l))
  131. browser.get(f_url_l_a)
  132. time.sleep(random.randint(10, 20))
  133.  
  134. js = 'window.location.href="https://sso.toutiao.com/login/";'
  135. js = 'window.location.href="https://sso.toutiao.com/login/?service=https://mp.toutiao.com/sso_confirm/?redirect_url=/";'
  136. browser.execute_script(js)
  137. time.sleep(random.randint(10, 20))
  138.  
  139. # js = 'window.location.href="https://sso.toutiao.com/login/?service=https%3A%2F%2Fwww.wukong.com%2Fwenda%2Fwelcome%2F#type=0";'
  140. browser.execute_script(js)
  141.  
  142. ac_type = 'qq'
  143. if ac_type == 'qq':
  144. myid, mypwd = ac['u'], ac['p']
  145. xp = '/html/body/div/div/div[2]/div/div/div/ul/li[3]'
  146. browser.find_element_by_xpath(xp).click()
  147. time.sleep(10)
  148. js = '%s%s%s' % ('document.getElementById("u").value="', myid, '"')
  149. browser.execute_script(js)
  150. js = '%s%s%s' % ('document.getElementById("p").value="', mypwd, '"')
  151. browser.execute_script(js)
  152. time.sleep(random.randint(5, 15))
  153. xp_newpage = '//*[@id="go"]'
  154. browser.find_element_by_xpath(xp_newpage).click()
  155. time.sleep(random.randint(10, 20))
  156. elif ac_type == 'mail_qq':
  157. continue
  158.  
  159. time.sleep(5)
  160.  
  161. browser.refresh()
  162. js = 'window.location.href="https://www.toutiao.com/";'
  163. browser.execute_script(js)
  164. browser.refresh()
  165.  
  166. time.sleep(6)
  167.  
  168. js = 'window.location.href="https://www.wukong.com/";'
  169. js = 'window.location.href="https://mp.toutiao.com/profile_v2/publish/";'
  170. js = 'window.location.href="https://mp.toutiao.com/profile_v3/graphic/publish";'
  171. browser.execute_script(js)
  172.  
  173. time.sleep(6)
  174.  
  175. # title
  176. # js = '%s%s%s' % ('document.getElementById("title").value="', '林志玲捐款记录被翻出 单笔高达千万', '"')
  177. # js = 'document.getElementById("title").value="{}"'.format('林志玲捐款记录被翻出 单笔高达千万')
  178. # browser.execute_script(js)
  179.  
  180. xp_newpage = '//*[@id="title"]'
  181. mytxt = '林志玲捐款记录被翻出 单笔高达千万'
  182. browser.find_element_by_xpath(xp_newpage).send_keys(Keys.SPACE)
  183. browser.find_element_by_xpath(xp_newpage).send_keys(mytxt)
  184.  
  185. time.sleep(2)
  186.  
  187. fhtml, dbhtml_str = 'toutaio.db.html', ''
  188. with open(fhtml, 'r', encoding='utf-8') as fr:
  189. for hi in fr:
  190. dbhtml_str = '{}{}'.format(dbhtml_str, hi.replace('\n', ''))
  191.  
  192. xp = '//*[@id="edui18_body"]/div[1]'
  193. # //*[@id="edui18_body"]/div[1]
  194. browser.find_element_by_xpath(xp).click()
  195. time.sleep(2)
  196. # //*[@id="images"]/div[1]/div
  197. xp = '//*[@id="images"]/div[1]/div'
  198. xp = '//*[@id="images"]/div[1]/div/span'
  199. browser.find_element_by_xpath(xp).click()
  200. time.sleep(1)
  201.  
  202. db_html = dbhtml_str
  203. # db_html = '<li ><img src="https://www.baidu.com/img/baidu_jgylogo3.gif" alt="qq_383" title="qq_3503"></li><li >qq_3203</li><li >2017年04月13日 10:02</li><li ><span>3074</span></li>'
  204. js = 'it=document.getElementById("ueditor_0").contentWindow.document.getElementsByTagName("body")[0];it.innerHTML="{}"'.format(
  205. db_html)
  206. browser.execute_script(js)
  207. xp = '//*[@id="edui18_body"]/div[1]'
  208. # //*[@id="edui18_body"]/div[1]
  209. browser.find_element_by_xpath(xp).click()
  210. time.sleep(2)
  211. # //*[@id="images"]/div[1]/div
  212. xp = '//*[@id="images"]/div[1]/div'
  213. xp = '//*[@id="images"]/div[1]/div/span'
  214. browser.find_element_by_xpath(xp).click()
  215. time.sleep(1)
  216. # xp='//*[@id="graphic"]/div/div/div[2]/div[2]/div[1]/div[2]/div/div/div[2]/div[1]/div[2]/i'
  217. # browser.find_element_by_xpath(xp)
  218. # xp='//*[@id="pgc-text-img"]/div/div[1]/div[1]'
  219. # browser.find_element_by_xpath(xp)
  220. xp = '//*[@id="pgc-text-img"]/div/div[2]/div/button[1]'
  221. browser.find_element_by_xpath(xp)
  222.  
  223. xp = '//*[@id="graphic"]/div/div/div[2]/div[2]/div[1]/div[2]/div/div/div/div/label[3]/div/input'
  224. browser.find_element_by_xpath(xp)
  225.  
  226. time.sleep(2)
  227. time.sleep(2)
  228. xp = '//*[@id="graphic"]/div/div/div[2]/div[3]/div[2]/div[1]'
  229. xp = '//*[@id="graphic"]/div/div/div[2]/div[3]/div[2]/div[1]'
  230. browser.find_element_by_xpath(xp).click()
  231. dd = 9
  232. # js = 'document.getElementsByClassName("ask")[0].click();'
  233. # browser.execute_script(js)
  234. # time.sleep(12)
  235.  
  236. # time.sleep(random.randint(10, 20))
  237. # # 需要键盘事件 反爬虫
  238. # tmp_target = browser.find_element_by_class_name('input-box').find_element_by_tag_name('input')
  239. # tmp_target.send_keys(Keys.SPACE)
  240. # tmp_target.send_keys(Keys.CONTROL, 'a')
  241. # tmp_target.send_keys(Keys.CONTROL, 'x')
  242. # tmp_target.send_keys(Keys.CONTROL, 'v')
  243. # tmp_target.send_keys(Keys.BACK_SPACE)
  244. # time.sleep(random.randint(10, 20))
  245.  
  246. # res_content = []
  247. for i in res_content[0:1]:
  248. dbid, content, img_list = i['id'], i['content'], i['img_list']
  249.  
  250. tmp_l = ['口红', '指甲油', '护发素', '沐浴露', '洗手液', '洗发水', '牙膏']
  251. tmp_l_1 = ['老人', '小孩', '白领', '前台妹子', '行政妹子', '大学生', '高中生']
  252. tmp_l_2 = ['类型', '特质', '种类', '价位', '原材料', '主要成分', '价格']
  253.  
  254. s = '{}{}{}{}{}{}{}'.format(str(random.randint(1, 12)), '月份,', random.choice(tmp_l_1), '适合使用什么',
  255. random.choice(tmp_l_2), '的', random.choice(tmp_l))
  256. js = 'document.getElementsByClassName("input-box")[0].childNodes[0].value="{}";'.format(s)
  257. browser.execute_script(js)
  258. time.sleep(12)
  259. #
  260. # tmp_target.send_keys(Keys.SPACE)
  261.  
  262. js = 'document.getElementsByClassName("step-btn next")[0].click();'
  263. browser.execute_script(js)
  264.  
  265. # step-btn submit
  266.  
  267. js = 'document.getElementsByClassName("step-btn submit")[0].click();'
  268. browser.execute_script(js)
  269. time.sleep(12)
  270.  
  271. #
  272. js = 'window.location.href="https://www.wukong.com/user/?uid={}&type=1";'.format(toutiao_uid)
  273. browser.execute_script(js)
  274. time.sleep(12)
  275. res_url = browser.find_element_by_class_name('question-title').find_elements_by_tag_name('a')[
  276. 0].get_attribute('href')
  277.  
  278. # print(i)
  279. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/div/div/div/textarea'
  280. # try:
  281. # browser.find_element_by_xpath(xp_newpage)
  282. # except Exception as e:
  283. # print(e)
  284. # break
  285. # browser.find_element_by_xpath(xp_newpage).click()
  286. # words = content
  287. # # Message: SyntaxError: unterminated string literal
  288. # mytxt = words.replace('\n', ' ').replace('\r', ' ').replace('\\br', ' ').replace('"', '“').replace("'", '‘')
  289. # # Message: SyntaxError: missing ; before statement
  290. # mytxt = mytxt.replace("'", '‘')
  291. # # 2000 头条
  292. # mytxt = mytxt[0:2000]
  293. # mytxt = '好消息' if len(mytxt.replace(' ', '')) == 0 else mytxt
  294. #
  295. # # 需要键盘事件 反爬虫
  296. # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.SPACE)
  297. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.CONTROL, 'a')
  298. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.CONTROL, 'x')
  299. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.CONTROL, 'v')
  300. # # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.BACK_SPACE)
  301. # time.sleep(random.randint(2, 5))
  302. #
  303. # try:
  304. # # js = '%s%s%s' % ('document.getElementsByTagName("textarea")[0].value="', '', '"')
  305. # # browser.execute_script(js)
  306. # js = '%s%s%s' % ('document.getElementsByTagName("textarea")[0].value="', mytxt, '"')
  307. # browser.execute_script(js)
  308. # time.sleep(3)
  309. # except Exception as jse:
  310. # print('.getElementsByTagName("textarea")--log-', jse)
  311. # continue
  312. #
  313. # browser.find_element_by_xpath(xp_newpage).send_keys(Keys.SPACE)
  314. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/div/div/div/div[1]/div[1]/span[1]/span'
  315. # browser.find_element_by_xpath(xp_newpage).click()
  316. # time.sleep(3)
  317. # try:
  318. # upload = browser.find_element_by_id('fileElem')
  319. #
  320. # logs_img = ''
  321. # img_url_list = img_list.split(',')
  322. #
  323. # for imgid in img_url_list:
  324. # img_url = 'http://192.168.2.212:83/file/get?type=star_joke&id=199'.replace('199', str(imgid))
  325. # local_img_path = spider_webimg_dl_return_local_img_path(img_dir, img_url,
  326. # local_default='default.DONOT_REMOVE.png')
  327. # print(local_img_path)
  328. # time.sleep(random.randint(2, 4))
  329. # logs_img += img_url
  330. # logs_img += local_img_path
  331. # upload.send_keys(local_img_path)
  332. # time.sleep(random.randint(3, 7))
  333. # except Exception as ee:
  334. # img_url_default = ''
  335. # img_url = img_url_default
  336. # local_img_path = spider_webimg_dl_return_local_img_path(img_dir, img_url,
  337. # local_default='default.DONOT_REMOVE.png')
  338. # sleep(2)
  339. # logs_img += img_url
  340. # logs_img += local_img_path
  341. # # upload.send_keys(local_img_path)
  342. # logging.exception(ee)
  343. #
  344. # try:
  345. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/ul'
  346. # browser.find_element_by_xpath(xp_newpage).click()
  347. # xp_newpage = '/html/body/div/div[2]/div[2]/div[1]/div/div/div/div/div[1]/div[2]/a'
  348. # browser.find_element_by_xpath(xp_newpage).click()
  349. #
  350. # time.sleep(random.randint(8, 20))
  351. # js = 'document.getElementsByClassName("ugc-mode-content")[0].getElementsByTagName("a")[0].target="_self"'
  352. # browser.execute_script(js)
  353. #
  354. # time.sleep(random.randint(2, 5))
  355. # xp_newpage = '/html/body/div/div[2]/div[2]/div[2]/ul/li[1]/div/div[2]/div/div[2]/a'
  356. # browser.find_element_by_xpath(xp_newpage).click()
  357. # time.sleep(random.randint(3, 6))
  358. # url_curr = browser.current_url
  359. #
  360. # with open('toutiao_success.log', 'a', encoding='utf-8') as f:
  361. # logs = '%s%s%s%s%s\n' % (
  362. # time.strftime('%Y%m%d_%H%M%S', time.localtime(time.time())), ac_type, myid[0:4], mytxt,
  363. # logs_img)
  364. # print(logs)
  365. # f.write(logs)
  366.  
  367. sql = 'INSERT INTO joke_joke_article_publish_result (article_id,article_url,time_script,toutiao_uid) VALUE("%s","%s","%s","%s");' % (
  368. dbid, res_url, int(time.time()), toutiao_uid)
  369. mysql_write(sql)
  370. print(sql)
  371. time.sleep(random.randint(20, 30))
  372. js = 'window.location.href="https://www.wukong.com/"'
  373. js = 'window.location.href="https://www.toutiao.com/"'
  374. browser.execute_script(js)
  375. # except Exception as e_url_jump:
  376. # print('e_url_jump', e_url_jump)
  377. try:
  378. browser.quit()
  379. except Exception as e1:
  380. print(e1)
  381. logging.exception(e1)
  382.  
  383. time.sleep(random.randint(120, 300))

  

  1. <img onload="editor.fireEvent('contentchange')" src="https://p1.pstatp.com/large/pgc-image/152385934210854ceb909ec" alt="pgc-image/152385934210854ceb909ec" _src="https://p1.pstatp.com/large/pgc-image/152385934210854ceb909ec" buttonadded="true">

  

  1. '''
  2. <img onload="editor.fireEvent('contentchange')" src="https://p1.pstatp.com/large/pgc-image/15238623686755f9e3c409a" _src="https://p1.pstatp.com/large/pgc-image/15238623686755f9e3c409a" alt="pgc-image/15238623686755f9e3c409a" buttonadded="true">
  3. '''
  4. dbhtml_str_ = dbhtml_str
  5. img_n = dbhtml_str_.count('<img')
  6. s = '<img onload="editor.fireEvent(\'contentchange\')" src="https://p1.pstatp.com/large/pgc-image/TTimgCode" _src="https://p1.pstatp.com/large/pgc-image/TTimgCode" alt="pgc-image/TTimgCode" buttonadded="true">'
  7. s = '<img onload="editor.fireEvent(\'contentchange\')" src="https://p1.pstatp.com/large/pgc-image/TTimgCode" _src="https://p1.pstatp.com/large/pgc-image/TTimgCode" alt="pgc-image/TTimgCode" buttonadded="true">'
  8. # s = "<img onload='editor.fireEvent(\'contentchange\')' src='https://p1.pstatp.com/large/pgc-image/TTimgCode' _src='https://p1.pstatp.com/large/pgc-image/TTimgCode' alt='pgc-image/TTimgCode' buttonadded='true'>"
  9. ss = ''
  10. l = pgc_img_url_l_toutiao
  11. for i in range(img_n):
  12. if i == 0:
  13. p1 = dbhtml_str.index('<img ', 0)
  14. else:
  15. p1 = dbhtml_str.index('<img ', p1 + 3)
  16.  
  17. tmp = '{}{}'.format(dbhtml_str[0:p1].replace('>', 'X'), dbhtml_str[p1:])
  18. p2 = tmp.index('>')
  19. ss = s.replace('TTimgCode', l[0].split('/')[-1])
  20. dbhtml_str = '{}{}{}'.format(dbhtml_str[0:p1], ss, dbhtml_str[p2 + 1:])
  21. del l[0]
  22. print('-----------------')
  23. print(dbhtml_str)
  24. time.sleep(2)
  25. js = 'window.location.href="https://mp.toutiao.com/profile_v3/graphic/publish";'
  26. browser.execute_script(js)
  27. time.sleep(6)
  28. xp_newpage = '//*[@id="title"]'
  29. mytxt = d['title']
  30. browser.find_element_by_xpath(xp_newpage).send_keys(Keys.SPACE)
  31. browser.find_element_by_xpath(xp_newpage).send_keys(mytxt)
  32. time.sleep(2)
  33.  
  34. # SAVE NOT DEL
  35. """
  36. xp = '//*[@id="edui18_body"]/div[1]'
  37. # //*[@id="edui18_body"]/div[1]
  38. browser.find_element_by_xpath(xp).click()
  39. time.sleep(2)
  40. xp = '//*[@id="images"]/div[1]/div/span'
  41. browser.find_element_by_xpath(xp).click()
  42. time.sleep(3)
  43. '''
  44. 'it=document.getElementById("ueditor_0").contentWindow.document.getElementsByTagName("body")[0];it.innerHTML="{}"'.format(dbhtml_str.replace('onload="editor.fireEvent(\'contentchange\')"','').replace('"',"'").replace('\n',''))
  45.  
  46. '''
  47. # 结合浏览器控制台,拼接符合语法的js字符串
  48. r_d = {'onload="editor.fireEvent(\'contentchange\')"': '', '"': "'", '\n': ''}
  49. dbhtml_str_py_js = dbhtml_str
  50. for k in r_d:
  51. dbhtml_str_py_js = dbhtml_str_py_js.replace(k, r_d[k])
  52. dbhtml_str_py_js = dbhtml_str_py_js.replace('nbsp;', ' ')
  53. js = 'document.getElementById("ueditor_0").contentWindow.document.getElementsByTagName("body")[0].innerHTML="{}"'.format(
  54. dbhtml_str_py_js)
  55. browser.execute_script(js)
  56. """
  57. # 激活编辑区
  58. browser.find_element_by_class_name('ql-container').click()
  59. # 进行上传图片圆圈操作
  60. browser.find_element_by_class_name('icon-pic_tool').click()
  61. # 激活目标上传口
  62. browser.find_element_by_class_name('tui-tab-list').find_elements_by_class_name('tui-tab')[-1].click()
  63. # 关闭上传口
  64. browser.find_element_by_class_name('tui-tab-panel-active').find_elements_by_class_name('tui-btn')[
  65. -1].click()
  66.  
  67. # 结合浏览器控制台,拼接符合语法的js字符串
  68. r_d = {'onload="editor.fireEvent(\'contentchange\')"': '', '"': "'", '\n': ''}
  69. dbhtml_str_py_js = dbhtml_str
  70. for k in r_d:
  71. dbhtml_str_py_js = dbhtml_str_py_js.replace(k, r_d[k])
  72. dbhtml_str_py_js = dbhtml_str_py_js.replace('nbsp;', ' ')
  73. #传入键盘化的html
  74. # document.getElementsByClassName("ql-editor ql-blank")[0].innerHTML = "44"
  75. js = 'document.getElementsByClassName("ql-editor ql-blank")[0].innerHTML ="{}"'.format(
  76. dbhtml_str_py_js)
  77. browser.execute_script(js)

  

文章编辑器 文本替换 操作dom 发帖 富文本 今日头条发布富文本的实现 键盘化的html的更多相关文章

  1. 【JavaScript实用技巧(二)】Js操作DOM(由问题引发的文章改版,新人大佬都可)

    [JavaScript实用技巧(二)]Js操作DOM(由问题引发的文章改版,新人大佬都可!) 博客说明 文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人 ...

  2. Javascript - ExtJs - 整合百度文章编辑器

    ExtJs - 整合百度文章编辑器(ExtJs UEditor) 第一步:去官网下载最新版本的UEditor,UEditor下载. 第二步:在编辑器根目录创建一个Extjs-Editor.js,录入以 ...

  3. 使用JavaScript操作DOM节点元素的常用方法(创建/删除/替换/复制等)

    getElementById(id)这是通过id来访问某一元素,最常用的之一,例:<html><body><div id="myid">test ...

  4. JavaScript 操作DOM对象

    1)JavaScript  操作DOM對象 1.DOM:是Document  Object  Model 的缩写,及文档对象模型 2.DOM通常分为三类:DOM Core(核心).HTML-DOM 和 ...

  5. jQuery操作DOM节点的方法总结

    1.parent():获得当前匹配元素集合中每个元素的父元素,该方法只会向上一级对 DOM 树进行遍历 $('li.item-a').parent().css('background-color', ...

  6. *jquery操作DOM总结 (原创:最全、最系统、实例展示)

    jquery操作DOM包括八个方面: 一:jquery对DOM节点的基本操作:二:jquery对DOM节点的CSS样式操作:三:jquery遍历DOM节点:四:jquery创建DOM节点:五:jque ...

  7. Angular开发实践(七): 跨平台操作DOM及渲染器Renderer2

    在<Angular开发实践(六):服务端渲染>这篇文章的最后,我们也提到了在服务端渲染中需要牢记的几件事件,其中就包括不要使用window. document. navigator等浏览器 ...

  8. jQuery——操作DOM

    所谓Web体验,就是Web服务器与Web浏览器之间的合作.过去,都是由服务器生成HTML文档,然后浏览器负责解释并显示该文档.后来,我们可以用CSS技术来动态修改页面的外观. ###操作属性 jQue ...

  9. Javascript操作DOM常用API总结

    基本概念 在讲解操作DOM的api之前,首先我们来复习一下一些基本概念,这些概念是掌握api的关键,必须理解它们. Node类型 DOM1级定义了一个Node接口,该接口由DOM中所有节点类型实现.这 ...

随机推荐

  1. 还是关于编码——decode & encode的探究

    最近被py3.4中的编码折磨的不要不要的,decode & encode的使用.功能貌似在2.7—3.0有一个巨大的变化.网上查询的一些解答很多是基于2.7中的unicode功能,给出的解答是 ...

  2. 6.11 将分割数据转换为多值IN列表

    问题 已经有了分隔数据,想要将其转换为WHERE子句IN列表中的项目.考虑下面的字符串: 7654,7698,7782,7788 要将该字符串用在WHERE子句中,但是下面的SQL语句是错误的,因为E ...

  3. parsley之验证属性设置

    parsley.js添加表单验证功能,直接在html元素中添加对应属性: Name API Description Required #2.0必填 required HTML5 data-parsle ...

  4. Intel Processor Exception Handling

    当一个进程的行为超出预期时,系统将把它kill掉. On Intel IA-32 and Intel 64 architecture processors, each architecturally- ...

  5. Vue实战之插件 sweetalert 的使用

    安装npm install sweetalert2@7.15.1 --save 封装 sweetalertimport swal from 'sweetalert2' export default { ...

  6. vue基础---介绍

    (1)声明式渲染 Vue.js 的核心是采用简洁的模板语法来声明式地将数据渲染进 DOM 的系统: ①文本 <div id="app"> {{ message }} & ...

  7. vuecli3.x config

    module.exports = { // 基本路径 baseUrl: process.env.NODE_ENV === 'production' ? '/' : '/', // 输出文件目录 out ...

  8. 我的第一次"闭包"应用

    结论: 闭包可以当作强类型语言如C++.Java的全局变量使用,非常巧妙 需求: ssm项目,使用pagehelper分页,在写前一页.后一页.第一页.最后一页等页面跳转时,遇到了问题,如果查询全部的 ...

  9. Crossword Answers UVA - 232

    题目大意 感觉挺水的一道题.找出左面右面不存在或者是黑色的格子的白各,然后编号输出一横向单词和竖向单词(具体看原题) 解析 ①找出各个格子的编号 ②对每个节点搜索一下 ③输出的时候注意最后一个数据后面 ...

  10. ORACLE 查看当前用户信息(用户,表视图,索引,表空间,同义词,存储过程,约束条件)

    1.用户 查看当前用户的缺省表空间 SQL>select username,default_tablespace from user_users; 查看当前用户的角色 SQL>select ...