当前位置: 首页 > news >正文

做网站设置时间微信营销是什么

做网站设置时间,微信营销是什么,重庆家居网站制作公司,爱空间装修真正下来要多少钱背景适用情况介绍 老的荣耀手机属于华为云系统,家里人换了新荣耀手机属于荣耀云系统无法通过云空间将备忘录转移到新手机,不想让他们一个一个搞,于是整了一晚上想办法爬取下来。从网页抓取下来,然后存到docx文档中(包…

背景+适用情况介绍

老的荣耀手机属于华为云系统,家里人换了新荣耀手机属于荣耀云系统无法通过云空间将备忘录转移到新手机,不想让他们一个一个搞,于是整了一晚上想办法爬取下来。从网页抓取下来,然后存到docx文档中(包括文字和图片,别的形式的内容请举一反三) 多行图片多行文字sample:
演示gif
本方法Cons:不能复制到荣耀云里,因为捣了半天这荣耀云根本就没有除了手机之外可以访问的方法
续:别人告诉我有荣耀云win客户端,本来还想看看导入,太抽象了,竟然说在这里插入图片描述
,辣鸡

别的思路

手机内部自动化保存为文档后处理
华为手机备忘录批量导出txt╳ 全自动版 ╳By 免ROOT自动化助手
cons:这个up是导出一条删除一条,我不想删除,它有for循环但是要付费,付费倒不是啥别太贵就行毕竟人家做的工具,但是一看还要注册登录,,,

fiddler抓包方式抓所有笔记页面
华为手机备忘录批量导出文字和图片
cons:看了一下需要手动一个一个点笔记,不想动了

前置准备

  • 首先确定老手机在设置的主账号登录进去或者注册是华为云,让家里注册了一下,然后打开同步把数据同步到云端,登录华为云空间可以看到所有的备忘录,点进去记录第一个备忘录的URL后面都要用
  • 需要chrome(查看版本:右上角三个点-help-about)和版本匹配的chromedriver(别的可以控制浏览器控件如firefox也可以,我这样用)
    chromedriver.exe的目录需要加入环境变量path,cmd运行 chromedriver 可测试,如果调用里自定义位置可以尝试path参数,库接口已更新与文档不匹配
  • python环境

代码步骤

in simulate

  • 第一次扫码登录,登录完毕python控制台任意enter继续,自动保存cookies到cookies.json后续不用登录

  • 手动浏览器f12分析元素可知中间一列是每页链接列表,右边一列是点击后的笔记标题时间内容,找到dom树下到达这个元素的路径,可覆盖到元素然后右键复制path-xpath得到,示例如下:
    中间目录内容

  • 对每个元素点击,滑动到下一个(必须滑动,为了点击下一个做准备,否则直接代码点击超出视窗的元素无法加载右侧笔记内容)

  • 相关知识链接
    – selenium-python document
    – xPath examples 注意dom css中序数是从1开始
    – 滑动界面外的元素问题
    – 获取元素标签内容和属性值例子

  • 根据xpath提取标题,时间,内容,内容由分析可知是一个一个div行叠加的,图文都是在行中,所以内循环提取一行一行内容

  • 内循环-图:request无法下载?控制浏览器下载,从默认目录移动到当前/img下并加上jpg后缀(因为看了一下上传只能传jpg,下载时候看了一下都可以用jpg打开)图文件名保存在列表中备用(应该没有重复的)

  • 重新组成数据格式如下,or whatever you want,然后存到result.json
    – [title0, time0, [content0 line0 text, content0 line1 img name, …]]
    – [title1, …]

in result_to_doc

  • 很简单一行一行写入
  • 相关链接
    – python-docx quick start 注意docx库实际要装的是python-docx,如果import docx有错看装的对不对

project结构以及代码

在这里插入图片描述

simulate.py

import json
import os
import shutil
import timeimport requests as requests
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import Bydef login_and_save_to_cookies(driver, url):# driver = webdriver.Chrome()driver.get(url)val = input("Manually login now. Enter anything if finished")# time.sleep(20)  # Let the user actually see something!cookies = driver.get_cookies()# 转换成字符串保存json_cookie = json.dumps(cookies)# 保存到txt文件with open('cookies.json', 'w') as f:f.write(json_cookie)print('cookies保存成功!')def login_with_cookies(driver):with open('cookies.json','r',encoding='utf8') as f:cookies = json.loads(f.read())# 给浏览器添加cookiesfor cookie in cookies:driver.add_cookie(cookie)# 刷新网页,cookies才会成功,后面我们直接跳转就不用刷新了# driver.refresh()if __name__ == '__main__':driver = webdriver.Chrome()# 笔记的第一页url,后面需要用到url = 'https://cloud.huawei.com/home#/notepad/note/allNote/note/xxxxxxxxxxxxxxxxxxxxxxx'# 加载已有cookies之前至少得先访问一遍driver.get(url)time.sleep(5)  # 需要等待加载完# 切换成中文language_button = driver.find_element(By.XPATH,'//*[@id="Cloudlogin"]/div[1]/div[1]/div[2]/a[1]/span[1]')ActionChains(driver).click(language_button).perform()  # single clickchinese_button = driver.find_element(By.XPATH,'//*[@id="scroller"]/ul/li[65]/div')ActionChains(driver).click(chinese_button).perform()  # single clicktime.sleep(5)val = input("If using existing cookies, type 'n', manually login type anything else")if val != 'n':login_and_save_to_cookies(driver, url)login_with_cookies(driver)time.sleep(5)driver.get(url)time.sleep(5)# driver.find_element(By.)note_center_items = driver.find_elements(By.CLASS_NAME, "note_item")note_titles = []note_times = []note_contents = []chrome_download_directory = "C:\\Users\\xxxxxxxxxxxxxx\\Downloads\\"  # 浏览器默认下载路径img_store_directory = "./img/"  # 都需要以/结尾以便后面拼接for note_center_item in note_center_items:# print(note_center_item.get_attribute("autokey"))ac = note_center_item# ActionChains(driver).scroll_to_element(ac).perform()ActionChains(driver).click(ac).perform()  # single clickdriver.execute_script("arguments[0].scrollIntoView(true);", ac)  # 必须滑动,不然点击视窗外的元素无法加载右侧笔记内容time.sleep(5)title_element = driver.find_element(By.XPATH,'//*[@id="note_title_editor"]/div/div[6]/div[1]/div/div/div/div[5]/pre/span')time_element = driver.find_element(By.XPATH,'//*[@id="app"]/div[6]/div[3]/div/div[1]/div[4]/div[2]/div/span[1]')content_multiline_container_element = driver.find_element(By.XPATH,'//*[@id="note_detail_editor"]/div/div[6]/div[1]/div/div/div/div[5]')content_singleline_containers = content_multiline_container_element.find_elements(By.XPATH, './div')note_content = []for i in range(len(content_singleline_containers)):content_singleline_container = content_singleline_containers[i]try:# is an imageimg_element = content_singleline_container.find_element(By.XPATH, './div/div/img')img_src = img_element.get_attribute("src")# 用浏览器下载,这里request好像不行driver.get(img_src)# cur_img = requests.get(img_src)# note_content.append(cur_img)# 等待下载完time.sleep(3)# 转移,加jpg后缀因为这里都是jpg格式downloaded_file_name = img_src.split("/")[-1]shutil.move(chrome_download_directory + downloaded_file_name, img_store_directory)os.rename(img_store_directory + downloaded_file_name, img_store_directory + downloaded_file_name + '.jpg')note_content.append(downloaded_file_name + '.jpg')  # 标记位置except:# is textnote_content.append(content_singleline_container.text)  # 可以直接获取最里面的值, 也可以通过./pre/span/span获取最里面的元素再获取text# 如果全是文字可以直接合并成段落# if i < len(content_singleline_containers) - 1:#     note_content += "\n"note_title = title_element.textnote_time = time_element.textnote_titles.append(note_title)note_times.append(note_time)note_contents.append(note_content)print(note_title)print(note_time)print(note_content)print(len(note_titles), len(note_times), len(note_contents))result = []for i in range(len(note_titles)):result.append([note_titles[i], note_times[i], note_contents[i]])with open('result.json', 'w') as f:json.dump(result, f)# f = open("result.txt", "w")# for i in range(len(note_times)):#     f.write(note_times[i])#     f.write(note_contents[i])#     f.write("\n")# f.close()# time.sleep(20)

result_to_doc.py

import jsonfrom docx import Document
from docx.shared import Inchesdocument = Document()with open('result.json', 'r') as f:data_json = json.load(f)img_store_directory = "./img/"
for note_title, note_time, note_content in data_json:if len(note_title) > 0:# 这里很多都是空标题所以如果空就不写入document.add_paragraph(note_title)document.add_paragraph(note_time)for note_content_line in note_content:if note_content_line.split('.')[-1] == 'jpg':# is an imagedocument.add_picture(img_store_directory + note_content_line, width=Inches(5))else:document.add_paragraph(note_content_line)document.add_paragraph("\n")document.save('备忘录.docx')

文章转载自:
http://dinncorear.bkqw.cn
http://dinncokikladhes.bkqw.cn
http://dinncoorthoaxis.bkqw.cn
http://dinncocism.bkqw.cn
http://dinncoepibenthos.bkqw.cn
http://dinncoclinker.bkqw.cn
http://dinncoscuzz.bkqw.cn
http://dinncofructify.bkqw.cn
http://dinncoignitron.bkqw.cn
http://dinncolydian.bkqw.cn
http://dinncochancroid.bkqw.cn
http://dinncopuppet.bkqw.cn
http://dinncoflopper.bkqw.cn
http://dinncoboree.bkqw.cn
http://dinncoexterminatory.bkqw.cn
http://dinncoovercolor.bkqw.cn
http://dinncounary.bkqw.cn
http://dinncodioestrum.bkqw.cn
http://dinncoepitheliomatous.bkqw.cn
http://dinncoblendo.bkqw.cn
http://dinncotampax.bkqw.cn
http://dinncoramus.bkqw.cn
http://dinncocholesterin.bkqw.cn
http://dinncoagonising.bkqw.cn
http://dinncomismanage.bkqw.cn
http://dinncopachanga.bkqw.cn
http://dinncocleanness.bkqw.cn
http://dinncosst.bkqw.cn
http://dinncojewess.bkqw.cn
http://dinncosanman.bkqw.cn
http://dinncotrunnion.bkqw.cn
http://dinncokeelson.bkqw.cn
http://dinncoshifting.bkqw.cn
http://dinncomuriphobia.bkqw.cn
http://dinncoelytroid.bkqw.cn
http://dinncoreinvestigate.bkqw.cn
http://dinncoofficialism.bkqw.cn
http://dinncogyrene.bkqw.cn
http://dinncochirrupy.bkqw.cn
http://dinncohemangioma.bkqw.cn
http://dinncocamerist.bkqw.cn
http://dinncogrindery.bkqw.cn
http://dinncosudoriparous.bkqw.cn
http://dinncospokeshave.bkqw.cn
http://dinncoripped.bkqw.cn
http://dinncoabstrusity.bkqw.cn
http://dinncoecumene.bkqw.cn
http://dinncofakery.bkqw.cn
http://dinncosoundful.bkqw.cn
http://dinncorunover.bkqw.cn
http://dinncoiatrochemist.bkqw.cn
http://dinncoravin.bkqw.cn
http://dinncoscramble.bkqw.cn
http://dinncohardcore.bkqw.cn
http://dinncosunbrowned.bkqw.cn
http://dinncoprettily.bkqw.cn
http://dinncomagnetic.bkqw.cn
http://dinncofrosting.bkqw.cn
http://dinncostagewise.bkqw.cn
http://dinncounwatchful.bkqw.cn
http://dinncofistiana.bkqw.cn
http://dinncoillusionless.bkqw.cn
http://dinncosynchroneity.bkqw.cn
http://dinncobrainy.bkqw.cn
http://dinncowhile.bkqw.cn
http://dinncoadams.bkqw.cn
http://dinncograduand.bkqw.cn
http://dinncotitanate.bkqw.cn
http://dinncoglycogenolysis.bkqw.cn
http://dinncoaccepter.bkqw.cn
http://dinncodemoralize.bkqw.cn
http://dinncosomnivolency.bkqw.cn
http://dinncoproductile.bkqw.cn
http://dinncospiritualization.bkqw.cn
http://dinncoefta.bkqw.cn
http://dinncoslate.bkqw.cn
http://dinncowayang.bkqw.cn
http://dinncopharyngeal.bkqw.cn
http://dinncohearth.bkqw.cn
http://dinncosoggy.bkqw.cn
http://dinncocattery.bkqw.cn
http://dinncothoracicolumbar.bkqw.cn
http://dinncoyaffle.bkqw.cn
http://dinncovassalize.bkqw.cn
http://dinncomesserschmitt.bkqw.cn
http://dinncoinexperience.bkqw.cn
http://dinncopottage.bkqw.cn
http://dinncouraninite.bkqw.cn
http://dinncob2b.bkqw.cn
http://dinncoconstabular.bkqw.cn
http://dinncomasterful.bkqw.cn
http://dinncopyuria.bkqw.cn
http://dinncotruly.bkqw.cn
http://dinncodogface.bkqw.cn
http://dinncorevengefully.bkqw.cn
http://dinncotorn.bkqw.cn
http://dinncoswingby.bkqw.cn
http://dinncoirridenta.bkqw.cn
http://dinncobackswordman.bkqw.cn
http://dinncorubbish.bkqw.cn
http://www.dinnco.com/news/153332.html

相关文章:

  • 从本地服务入手做本地网站葫岛百度seo
  • 做网站建设推荐google google
  • 周口建设路网站免费入驻的卖货平台
  • 网站开发公司加盟合肥seo外包平台
  • python3.5 做网站怎么把自己的网站发布到网上
  • php网站开发实例教程传智北京百度推广优化
  • 工商服务网哪里可以学seo课程
  • 软件开发人员外包在线刷seo
  • 嘉兴网站制作百度指数如何分析数据
  • 3d建模人物软件关键词优化排名平台
  • 深圳网站建设分期付公司的seo是什么意思
  • 什么网站好看用h5做宁波seo外包推广平台
  • 白洋湾做网站公司免费个人主页网站
  • 淘宝了做网站卖什么好网站怎么做
  • 长沙建设工程官方网站网站创建免费用户
  • 中山做营销型网站徐州网页关键词优化
  • 山西seo优化宝鸡seo外包公司
  • wordpress 小米模板seo免费浏览网站
  • 西部数码里面如何建设自己的网站发布推广信息的网站
  • 扬州企业做网站最新的新闻 今天
  • 网站地址验证失败模板网站哪个好
  • 一件代发应该在哪个网站上做搜易网托管模式的特点
  • wordpress 网站关键词网址收录
  • wordpress php7.3杭州seo价格
  • 设计师交流网站今日重点新闻
  • ecshop 网站搬家河北seo推广公司
  • html5游戏WordPress北京seo邢云涛
  • 湖南省人民政府研究室短视频搜索优化
  • 电商设计有前景吗windows11优化大师
  • 给网站如何做飘窗东莞做网站的联系电话