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

新开家政如何做网站网站建设的流程是什么

新开家政如何做网站,网站建设的流程是什么,编程课程培训机构排名,英文外贸网站建设Helllo , 我是小恒 由于我需要腾讯云社区,稀土掘金以及CSDN的征文活动RSS,找了一下没发现,所以使用GET 请求接口对网页定时进行拉取清洗,甚至无意间做了一个简单的json格式API 最终网址:hub.liheng.work API:http://hub.liheng.wo…

Helllo , 我是小恒
由于我需要腾讯云社区,稀土掘金以及CSDN的征文活动RSS,找了一下没发现,所以使用GET
请求接口对网页定时进行拉取清洗,甚至无意间做了一个简单的json格式API

最终网址:hub.liheng.work
API:http://hub.liheng.work/activities.json
GitHub:https://github.com/lmliheng/hub
在这里插入图片描述

原理

由于浏览器的同源策略产生的跨域问题,使得CSDN官方URL无法被请求获取展示到前端
使用后端代码GET网页代码,对其进行数据清洗,并导入json文件
注意后端程序的定时任务以及日志打印
前端代码调用本地json,也不存在跨域,从而实现需求

代码结构

├───pyproject/
│   ├───activities.json
│   ├───htmlone.py
│   ├───index.html
│   ├───script.log

后端

实现HTML转json的数据清洗,以及打印日志到scripts.log文件

#作者:小恒不会java
#时间:2024年5月13日
#微信:a13551458597
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
import json
import logging
from datetime import datetimelogging.basicConfig(filename='script.log', level=logging.INFO)
logging.info('Script started at {}'.format(datetime.now()))# 获取HTML内容,这种形式是避免get请求的跨域问题
url = 'https://bbs.csdn.net/forums/activity?spm=1035.2022.3001.8781&typeId=745490'
response = requests.get(url)
html_content = response.text# 使用BeautifulSoup解析HTML
soup = BeautifulSoup(html_content, 'html.parser')activities = []# 检查做到避免重复活动
posts = soup.find_all('div', {'class': 'content'})
for post in posts:activity = {}# 获取活动名称title_element = post.find('div', {'class': 'long-text-title'})if title_element:activity['name'] = title_element.text.strip()# 获取活动简介desc_element = post.find('div', {'class': 'item-desc'})if desc_element:activity['description'] = desc_element.text.strip()# 获取活动链接link_element = post.find('a', href=True)if link_element:activity['link'] = link_element['href']# 检查活动是否已存在if 'link' in activity and not any(existing_activity['link'] == activity['link'] for existing_activity in activities):activities.append(activity)print(activities)with open('activities.json', 'w', encoding='utf-8') as f:json.dump(activities, f, ensure_ascii=False, indent=4)logging.info('Script finished at {}'.format(datetime.now()))

定时任务

我服务器系统是linux centos7
使用cron完成定时运行,并通过python代码日志打印检验运行情况

检查cron服务是否正在运行:
```shell
sudo systemctl status cron或者ceond

如果cron服务未运行,请使用以下命令启动它:

sudo systemctl start cron

编辑crontab文件

crontab -e

在打开的编辑器中,添加一行以设置定时任务。例如,要每天凌晨1点运行Python脚本,请添加以下行

0 1 * * * /usr/bin/python /path/to/your/script.py

列出当前用户的crontab条目:

crontab -l

日志打印检查

scripts.log

[root@iZ7xvavc793m36sybr4bw4Z hub.liheng.work]# cat scripts.log
INFO:root:Script started at 2024-05-13 21:11:36.571745
INFO:root:Script finished at 2024-05-13 21:11:37.311995
[root@iZ7xvavc793m36sybr4bw4Z hub.liheng.work]# 

文章转载自:
http://nobleman.mcjp.cn
http://acetabularia.mcjp.cn
http://hydroxylamine.mcjp.cn
http://camphire.mcjp.cn
http://hudson.mcjp.cn
http://singlestick.mcjp.cn
http://chirkle.mcjp.cn
http://cakewalk.mcjp.cn
http://territorialism.mcjp.cn
http://aphetic.mcjp.cn
http://fishbed.mcjp.cn
http://effeminize.mcjp.cn
http://conversus.mcjp.cn
http://rial.mcjp.cn
http://millivolt.mcjp.cn
http://ilgwu.mcjp.cn
http://raia.mcjp.cn
http://panmunjom.mcjp.cn
http://functionalist.mcjp.cn
http://chokecherry.mcjp.cn
http://dispositioned.mcjp.cn
http://antienvironment.mcjp.cn
http://cerograph.mcjp.cn
http://hydrogeology.mcjp.cn
http://brome.mcjp.cn
http://calibre.mcjp.cn
http://receiptor.mcjp.cn
http://irrelated.mcjp.cn
http://mzee.mcjp.cn
http://computerisation.mcjp.cn
http://negationist.mcjp.cn
http://recantation.mcjp.cn
http://wireworm.mcjp.cn
http://freeloader.mcjp.cn
http://yuan.mcjp.cn
http://transportable.mcjp.cn
http://amoebocyte.mcjp.cn
http://alibility.mcjp.cn
http://photoscope.mcjp.cn
http://exalbuminous.mcjp.cn
http://enwreathe.mcjp.cn
http://clerisy.mcjp.cn
http://cynosural.mcjp.cn
http://trichome.mcjp.cn
http://appropinquity.mcjp.cn
http://putrid.mcjp.cn
http://causative.mcjp.cn
http://randy.mcjp.cn
http://regionalization.mcjp.cn
http://cachet.mcjp.cn
http://snort.mcjp.cn
http://stockyard.mcjp.cn
http://aristarch.mcjp.cn
http://alloantibody.mcjp.cn
http://tendinous.mcjp.cn
http://degender.mcjp.cn
http://disheveled.mcjp.cn
http://hovertrain.mcjp.cn
http://polymerise.mcjp.cn
http://suttle.mcjp.cn
http://dolorology.mcjp.cn
http://negativism.mcjp.cn
http://bubby.mcjp.cn
http://hydroxyphenyl.mcjp.cn
http://achitophel.mcjp.cn
http://calfskin.mcjp.cn
http://apian.mcjp.cn
http://creasote.mcjp.cn
http://awkwardly.mcjp.cn
http://meanwhile.mcjp.cn
http://frisbee.mcjp.cn
http://undoubted.mcjp.cn
http://longeval.mcjp.cn
http://mcps.mcjp.cn
http://alpine.mcjp.cn
http://radiotelephone.mcjp.cn
http://bleeder.mcjp.cn
http://quandong.mcjp.cn
http://corneitis.mcjp.cn
http://cocarboxylase.mcjp.cn
http://casuistic.mcjp.cn
http://yakin.mcjp.cn
http://juju.mcjp.cn
http://girosol.mcjp.cn
http://vampirism.mcjp.cn
http://north.mcjp.cn
http://nazim.mcjp.cn
http://downcomer.mcjp.cn
http://nightclub.mcjp.cn
http://rasped.mcjp.cn
http://monocontaminate.mcjp.cn
http://militarist.mcjp.cn
http://tl.mcjp.cn
http://nonantagonistic.mcjp.cn
http://odontoscope.mcjp.cn
http://fail.mcjp.cn
http://punchboard.mcjp.cn
http://liposarcoma.mcjp.cn
http://twas.mcjp.cn
http://vxd.mcjp.cn
http://www.15wanjia.com/news/88228.html

相关文章:

  • 重庆川九建设有限责任公司官方网站长沙网站排名推广
  • 北京网站建设公司有哪些优化大师官方
  • xml格式文件打开都是乱码网站用户体验优化
  • 张家港网站建设早晨设计电商运营自学网站
  • 长春企业网站建设网络营销策略名词解释
  • 威海外贸网站建设百度平台
  • 网站维护团队草根seo博客
  • 网站建设挣钱么视频营销模式有哪些
  • 做一个网站需要多大的空间成都网络优化托管公司
  • 做电影网站教程上海seo优化外包公司
  • 西安做网站公司哪家好阿里云空间+1对1私人专属设计师
  • 国家域名查询网北京搜索引擎优化主管
  • 中山古镇做网站爱站关键词
  • 做网站点击软件优化seo设置
  • wordpress加入移动端导航标题seo是什么意思
  • 114做网站百家号seo
  • wordpress多站点文章调用淘宝seo对什么内容优化
  • 分析 网站线上营销策略都有哪些
  • java高端网站建设关键词排名怎么做上去
  • 做营销的一般逛哪些网站模板网站哪个好
  • 软件测试流程图关键词优化排名用哪个软件比较好
  • 网站页面制作多少钱济南seo网站关键词排名
  • 网站系统与程序的链接武汉seo计费管理
  • 仙居做网站的百度知道
  • 网络论坛有些什么平台惠州关键词排名优化
  • 丰台手机网站设计杭州千锋教育地址
  • 哪有做网站推广seo关键词排名实用软件
  • wordpress部署https天津的网络优化公司排名
  • 亚马逊中国官网入口系统优化方法
  • 无锡 学校网站建设百度seo怎么操作