广告位

您现在的位置是:主页 > SEO相关技术 >

日照SEO外包该找谁做优化?日照SEO该怎么优化?

2020-01-18 00:25SEO相关技术 人已围观

简介日照搜索引优化 import os import shutil with open(1.txt) as fw: while 1: fs = fw.readline().split(\n)[0] if not fs: break try: try: os.rename(rD:\phpstudy\PHPTutorial\WWW\{}\admin.format(fs),rD:\phpstudy\PHPTutorial\WWW\{}\hrseoadmin....

日照搜索引优化
import os
import shutil
 
with open('1.txt') as fw:
    while 1:
        fs = fw.readline().split('\n')[0]
        if not fs:
            break
        try:
            try:
                os.rename(r'D:\phpstudy\PHPTutorial\WWW\{}\admin'.format(fs),r'D:\phpstudy\PHPTutorial\WWW\{}\hrseoadmin'.format(fs))
            except FileNotFoundError:
                os.rename(r'D:\phpstudy\PHPTutorial\WWW\{}\dede'.format(fs),r'D:\phpstudy\PHPTutorial\WWW\{}\hrseodede'.format(fs))
        except Exception as ex:
            print(ex)
# -*- coding=utf-8 -*-
import re
import time
from threading import Thread
 
import requests
from selenium import webdriver
from selenium.common.exceptions import ElementNotVisibleException,TimeoutException,NoSuchElementException
from selenium.webdriver import ActionChains, DesiredCapabilities
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as Ec
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
 
 
class Dede:
    def __init__(self,url,de):
        self.url = url
        self.de = de
        desired_capabilities = DesiredCapabilities.CHROME
        desired_capabilities["pageLoadStrategy"] = "none"
        chrome_options = webdriver.ChromeOptions()
        # headless not view borwer
        chrome_options.add_argument('--headless')
        chrome_options.add_argument('--disable-gpu')
        self.driver = webdriver.Chrome(r'MIP自动安装\chromedriver.exe',chrome_options=chrome_options)  #
        self.wait = WebDriverWait(self.driver, 360)
        self.driver.set_page_load_timeout(5)  # setting wait time
 
    def login(self):
        url = '{}/sys_cache_up.php'.format(self.url)
        self.driver.get(url)
        time.sleep(3)
        if self.driver.title.find('织梦内容管理系统') == -1:
            return False
        #Wait View Refresh
        self.wait.until(Ec.visibility_of_all_elements_located((By.NAME,'userid')))
        #Input useadmin
        self.driver.find_element_by_name('userid').send_keys('buji')
        #Input PASSWORD
        self.driver.find_element_by_name('pwd').send_keys('admin')
        #Submit
        self.driver.find_element_by_name('sm1').click()
 
    #Update Parts Html
    def sys_cache_up(self):
        self.wait.until(Ec.visibility_of_all_elements_located((By.CSS_SELECTOR,'input[value="开始执行"]')))
        self.driver.find_element_by_css_selector('input[value="开始执行"]').click()
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('stafrm')
        # print(' {}cache come to stafrm'.format(self.url))
        if self.de == 'hrseodede':
            self.wait.until(Ec.visibility_of_all_elements_located((By.XPATH, "//div[contains(text(),'成功更新所有缓存!')]")))
        elif self.de == 'hrseoadmin':
            self.wait.until(Ec.visibility_of_all_elements_located((By.XPATH, "//span[contains(text(),'成功更新所有缓存!')]")))
        # print('------------------ Parts is update succeed {} ------------------'.format(self.url))
 
    def makehtml_homepage(self):
        JS = 'window.open("{}/makehtml_homepage.php")'.format(self.url)
        self.driver.execute_script(JS)
        header = self.driver.window_handles
        self.driver.switch_to.window(header[1])
        self.wait.until(Ec.visibility_of_all_elements_located((By.NAME,'Submit')))
        self.driver.find_element_by_name('Submit').click()
        self.driver.switch_to.frame('stafrm')
        # print(' {}Index come to stafrm'.format(self.url))
        self.wait.until(Ec.visibility_of_all_elements_located((By.LINK_TEXT,"浏览...")))
        # print('------------------ Index is update succeed {} ------------------'.format(self.url))
 
    def listupdate(self):
        JS = 'window.open("{}/makehtml_list.php")'.format(self.url)
        self.driver.execute_script(JS)
        header = self.driver.window_handles
        self.driver.switch_to.window(header[2])
        self.wait.until(Ec.visibility_of_all_elements_located((By.CSS_SELECTOR,'input[value="开始生成HTML"]')))
        self.driver.find_element_by_css_selector('input[value="开始生成HTML"]').click()
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('stafrm')
        # print(' {}List come to stafrm'.format(self.url))
        if self.de == 'hrseodede':
            self.wait.until(Ec.visibility_of_all_elements_located((By.XPATH, "//div[contains(text(),'完成所有栏目列表更新!')]")))
        elif self.de == 'hrseoadmin':
            self.wait.until(Ec.visibility_of_all_elements_located((By.XPATH, "//span[contains(text(),'完成所有栏目列表更新!')]")))
        # print('------------------ list_arcitive is update succeed {} ------------------'.format(self.url))
 
    def update_archives(self):
        JS = 'window.open("{}/makehtml_archives.php")'.format(self.url)
        self.driver.execute_script(JS)
        header = self.driver.window_handles
        self.driver.switch_to.window(header[3])
        self.wait.until(Ec.visibility_of_all_elements_located((By.CSS_SELECTOR, 'input[value="开始生成HTML"]')))
        self.driver.find_element_by_css_selector('input[value="开始生成HTML"]').click()
        self.driver.switch_to.default_content()
        self.driver.switch_to.frame('stafrm')
        # print(' {}arctive come to stafrm'.format(self.url))
        if self.de == 'hrseodede':
            self.wait.until(Ec.visibility_of_all_elements_located((By.XPATH, "//div[contains(text(),'完成所有创建任务!')]")))
        elif self.de == 'hrseoadmin':
            self.wait.until(Ec.visibility_of_all_elements_located((By.XPATH, "//span[contains(text(),'完成所有创建任务!')]")))
        # print('------------------ arctives_arcitive is update succeed {} ------------------'.format(self.url))
 
    def close_dede(self):
        header = self.driver.window_handles
        for heads in range(len(header)):
            self.driver.close()
            try:
                self.driver.switch_to.window(header[heads])
            except Exception:
                print('------------------ Close is windwo_headers {} ------------------'.format(self.url))
 
    def main(self):
        stat = self.login()
        if stat == False:
            print(self.url, '该域名出现问题,已跳过,请查看')
            self.driver.close()
            return
        self.sys_cache_up()
        self.makehtml_homepage()
        self.listupdate()
        self.update_archives()
        self.close_dede()
 
def url_de_ad_succeed(url):
    title = requests.get(url+'/hrseodede')
    if title.status_code == 200:
        return 'hrseodede'
    return 'hrseoadmin'
 
def threing_main(urls):
    for url in urls:
        ur = url_de_ad_succeed(url)
        dedeupdate = Dede(url+'/'+ur,ur)
        dedeupdate.main()
 
def file_url(file):
    urls = set()
    with open(file,encoding='utf8') as fr:
        while 1:
            dede_url = fr.readline().split('\n')[0]
            if not dede_url:
                break
            urls.add(dede_url)
        return urls
#可后续
def xiancheng(files,xiancheng_number):
    lis_li = []
    for li in range(xiancheng_number):
        lists = []
        lis_li.append(lists)
    num = 0
    for fi in files:
        lis_li[num].append(fi)
        if num == xiancheng_number - 1:
            lis_li[num].append(fi)
            num = 0
            continue
        num += 1
    return lis_li
import re
 
import pymysql
 
def jieci(tas):
    tag_num = tas.find('}') + 1
    tags = tas[:tag_num]
    cengji = tas[tag_num:]
    res = re.compile('[\s\S]*?/')
    re_list = re.findall(res, cengji)
    for li in re_list:
        cengji = cengji.replace(li, '', 1)
    dirs = tags + '/' + cengji
    return dirs
mysql_list = []
with open('url.txt',encoding='utf8') as fw:
    while 1:
        mysql_lists = fw.readline().split('\n')[0]
        if not mysql_lists:
            break
        mysql_list.append(mysql_lists)
for mysql in mysql_list:
    print(mysql,'运行')
    conn = pymysql.connect(
        host="localhost",
        user="root",
        password="root",
        database=mysql,
        charset="utf8")
    cursor = conn.cursor()
 
    # sql = 'select id,typedir,namerule from dede_arctype;'
    sql = "update dede_admin set userid='buji' where userid='admin';"
    # 执行SQL语句
    cursor.execute(sql)
 
    # all = cursor.fetchall()
    #
    #
    # for x in all:
    #     #标签
    #     dirs = jieci(x[1])
    #     namerule = jieci(x[2])
    #     sqs = 'update dede_arctype set typedir="{}" where id={};'.format(dirs,x[0])
    #     sqd = 'update dede_arctype set sitepath="{}" where id={};'.format(dirs,x[0])
    #     sqde = 'update dede_arctype set namerule="{}" where id={};'.format(namerule,x[0])
    #     cursor.execute(sqs)
    #     cursor.execute(sqd)
    #     cursor.execute(sqde)
    # 关闭光标对象
    cursor.close()
 
    # 关闭数据库连接
    conn.close()
 
if __name__ == '__main__':
    files = file_url('url.txt') # You can change the file name
    list_x = xiancheng(files,5)
    jin = []
    try:
        for th in range(5): # His number is the number of threads you can change
            thr = Thread(target=threing_main,args=(list_x[th],))
            jin.append(thr)
        for x in jin:
            x.start()
        for x in jin:
            x.join()
    except Exception as es:
        print('出现错误,错误对象',es)
 

如果您的问题没有得到解决可以联系五季度网站优化管理员或者直接添加管理员QQ:2642657068

Tags: 日照SEO  日照网站优化