REC
首页
网站建设
Typecho插件
Typecho教程
Wordpress插件
Wordpress教程
美食分享
素食主义
蛋白肉食
美味汤食
文章分类
游戏更新
文笔记录
学习一角
文章分享
新闻早报
动漫分享
程序软件
其他页面
网站统计
友情链接
关于博主
热门文章
一键将网页打包成很小的桌面 App,30.1K Star,更小,更轻量
基于国外服务器搭建自己的VPN详细教程
浪漫庄园公告自动发布
typecho joe主题优化日志
账号综合管理工具更新记录
标签搜索
教程
代码
桌面软件
linux
游戏工具
优化
工具破解
Typecho
博客博客
Typecho插件
美食
下厨房
牛奶咖啡
C#
NETcore8.0
游戏资料
二建
法规
笔记
2025
发布
登录
注册
找到
5
篇与
代码心得
相关的结果
2025-03-12
浪漫庄园综合查询网页版
浪漫庄园综合查询 网页制作记录 相关代码 主页代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>浪漫庄园综合查询--游戏资讯一手掌握</title> <link rel="stylesheet" href="/css/styles.css"> <!-- 引入favicon --> <link rel="icon" href="img/lm.ico" type="image/x-icon"> </head> <body> <div id="container"> <div id="sidebar"> <div id="logo"> <a href="/" style="text-decoration:none;"> <svg t="1741755903244" class="icon" viewBox="0 0 2214 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4354" width="200" height="200"><path d="M1694.422326 163.982884c32.232186 0 52.962233 16.14586 59.773023 45.282232l0.619163 2.857675 51.98586 330.859162 144.336372-330.859162c13.145302-29.93414 45.472744-47.020651 75.525954-48.092279l2.988651-0.047628h184.796279l-361.067163 677.804651c-72.656372 128.833488-181.045581 176.580465-274.217674 177.925953l-4.048372 0.023814H1394.783256l22.742325-136.168186c8.108651-35.280372 24.409302-51.509581 49.021024-52.509767l2.488558-0.059535h102.4c45.877581 0 89.683349-37.197395 97.875349-83.051163a80.538791 80.538791 0 0 0-0.452465-30.958139l-0.881117-3.548279-156.386232-549.459349h182.831628z m456.263441 555.16279c17.717581 0 32.744186 6.239256 45.067907 18.622512 12.466605 12.502326 18.693953 27.52893 18.693954 45.103628 0 17.622326-6.239256 32.696558-18.693954 45.067907-12.323721 12.383256-27.350326 18.741581-45.067907 18.741581-17.538977 0-32.553674-6.346419-45.067907-18.741581-12.40707-12.371349-18.682047-27.433674-18.682046-45.067907 0-17.574698 6.274977-32.601302 18.693953-45.103628 12.502326-12.383256 27.517023-18.622512 45.056-18.622512z m0 9.370791c-14.717023 0-27.338419 5.286698-37.864186 15.955349-10.35907 10.597209-15.550512 23.385302-15.550511 38.4-0.011907 15.074233 5.167628 27.88614 15.562418 38.435721 10.51386 10.63293 23.099535 15.919628 37.852279 15.919628 14.752744 0 27.52893-5.286698 37.947535-15.919628 10.537674-10.549581 15.812465-23.361488 15.812465-38.435721 0-14.990884-5.274791-27.790884-15.812465-38.4-10.418605-10.668651-23.230512-15.955349-37.947535-15.955349z m3.012466 19.360744c6.120186 0 11.323535 2.083721 15.598139 6.036838 4.226977 4.012651 6.489302 8.989767 6.489302 14.88372 0 9.061209-4.429395 15.264744-13.133395 18.539163l-1.940837 0.654884 16.788837 29.767442h-11.323535l-16.014884-28.517209h-10.537674v28.529116h-9.644651v-69.893954h23.718698z m-1.071628 8.584931h-13.002419v24.528372h13.002419c3.869767 0 7.025116-1.238326 9.477953-3.42921a11.252093 11.252093 0 0 0 3.691163-8.775442 11.561674 11.561674 0 0 0-3.691163-8.811162 12.514233 12.514233 0 0 0-7.858605-3.441117l-1.619348-0.071441zM254.654512 0c52.962233 0 79.074233 20.71814 71.096558 72.58493l-0.500093 3.095814-15.562419 88.18307h124.058791l-27.338419 154.921674H282.278698l-33.815814 191.821396c-8.049116 46.020465 20.801488 64.571535 51.950139 71.668093l4.465117 0.928744c0.738233 0.154791 1.488372 0.285767 2.226604 0.416744l4.465116 0.714419 2.226605 0.321488 4.417488 0.535814 4.369861 0.416744 4.286512 0.309582 4.167441 0.214325 6.024931 0.178605 3.810232 0.035721 6.167814-0.047628 7.906233-0.190512 4.274604-0.202418-30.350883 172.770232-9.180279 0.976372-6.394047 0.547721-4.88186 0.309582-5.524838 0.238139-6.286883 0.166698c-1.119256 0.011907-2.28614 0.035721-3.476838 0.035721l-9.454139-0.011907-8.977861-0.178605-6.191627-0.214325-6.334512-0.297675-6.489302-0.39293-6.596465-0.488186-6.715535-0.595349-6.810791-0.714419-6.882233-0.833488-6.953674-0.964465-3.500651-0.535814-7.025116-1.166884-7.048931-1.309767C118.164837 736.327442 28.612465 685.460837 51.08093 542.886698l0.988279-5.917768 38.364279-218.183442H0l27.231256-154.921674h89.552372L145.622326 0h109.044093z m630.569674 158.077023c1.357395 0 2.714791 0.035721 4.048372 0.095256l3.917395 0.23814 3.667349 0.333395 4.810419 0.595349 6.310698 1.035907-34.458791 195.34586-3.786419-0.738232-5.310511-0.833489-5.35814-0.66679-4.167442-0.428652-4.619907-0.357209a227.542326 227.542326 0 0 0-2.476651-0.166698l-5.262884-0.250046a239.211163 239.211163 0 0 0-5.655814-0.130977l-2.976744-0.023814c-1.595535 0-3.214884 0.011907-4.893767 0.059535l-5.108093 0.166698-5.298605 0.297674-5.477209 0.452465-5.643907 0.595349-2.869582 0.357209-5.846325 0.86921c-45.32986 7.358512-101.364093 31.648744-135.930047 100.637767-9.882791 20.36093-17.610419 44.81786-23.170976 73.978047l-1.154977 6.322604-38.554791 219.469396h-198.608372l104.209861-591.348093h106.603162c52.986047 0 78.990884 20.75386 70.989396 72.632558l-0.500093 3.095814-11.668838 65.512186c39.709767-80.610233 125.868651-147.134512 214.242233-147.146419z" fill="#323E48" p-id="4355"></path><path d="M1297.205581 170.960372c124.189767 37.364093 214.539907 152.504558 214.539907 288.577488 0 166.411907-134.906047 301.425116-301.472744 301.401303-3.798326 0-7.608558-0.083349-11.394977-0.23814l-5.643907-0.297674 31.851163-180.593116c59.915907-7.322791 106.472186-58.201302 106.472186-120.28428 0-45.829953-25.48093-85.670698-63.071256-106.269767l-3.155348-1.666977 31.874976-180.628837z m-86.849488-12.811907c3.774512 0 7.596651 0.11907 11.394977 0.309582l5.691535 0.321488-31.815442 180.61693c-59.915907 7.179907-106.555535 58.463256-106.555535 120.153302 0 45.770419 25.540465 85.77786 63.106977 106.293582l3.143442 1.666977-31.791628 180.736c-124.201674-37.376-214.587535-152.576-214.587535-288.708466 0-166.292837 134.977488-301.389395 301.413209-301.389395z" fill="#00ADBB" p-id="4356"></path></svg> </a> </div> <ul id="nav"> <li data-page="home"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M527.701333 179.768889a21.504 21.504 0 0 0-31.402666 0L155.136 536.746667a32.597333 32.597333 0 0 0-7.850667 19.569777v453.12H395.946667v-267.946666c0-62.748444 50.858667-113.607111 113.550222-113.607111h5.006222c62.691556 0 113.550222 50.858667 113.550222 113.607111v267.946666h248.661334V556.259556a32.654222 32.654222 0 0 0-7.850667-19.569778L527.701333 179.768889z m472.120889 309.191111L547.271111 29.468444a49.493333 49.493333 0 0 0-70.656 0L24.177778 488.96a33.223111 33.223111 0 0 0 47.217778 46.648889L512 88.177778l440.604444 447.374222a33.109333 33.109333 0 1 0 47.217778-46.648889z" fill="#1DECFE"></path> </svg> 首页 </li> <li data-page="price"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M192 672c19.2 0 32 12.8 32 32v128c0 19.2-12.8 32-32 32s-32-12.8-32-32v-128c0-19.2 12.8-32 32-32zM416 480c19.2 0 32 12.8 32 32v320c0 19.2-12.8 32-32 32s-32-12.8-32-32V512c0-19.2 12.8-32 32-32zM608 608c19.2 0 32 12.8 32 32v192c0 19.2-12.8 32-32 32s-32-12.8-32-32v-192c0-19.2 12.8-32 32-32zM832 448c19.2 0 32 12.8 32 32v352c0 19.2-12.8 32-32 32s-32-12.8-32-32V480c0-19.2 12.8-32 32-32z" fill="#597EF7" p-id="2626"></path><path d="M419.2 323.2l-246.4 246.4c-12.8 12.8-32 12.8-44.8 0-12.8-12.8-12.8-32 0-44.8l291.2-291.2 192 192 217.6-217.6c12.8-12.8 32-12.8 44.8 0 12.8 12.8 12.8 32 0 44.8l-262.4 262.4-192-192z" fill="#50E3C2"></path> </svg> 价格 </li> <li data-page="zhanshi"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M0 979.2c0 25.6 19.2 44.8 44.8 44.8h934.4c25.6 0 44.8-19.2 44.8-44.8v-704H0v704z m595.2-371.2h256v83.2h-256V608zM512 774.4h339.2v83.2H512v-83.2z m-19.2-544H0L102.4 51.2c12.8-19.2 38.4-32 64-32h320v211.2z m531.2 0H537.6V25.6h320c25.6 0 51.2 12.8 64 32L1024 230.4z" fill="#409EFF" p-id="10926"></path> </svg> 展示 </li> <li data-page="gongju"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M400.85 95.19c-0.23 0-0.46 0.02-0.69 0.02-42.02 0.1-81.91 9.18-117.94 25.33l194.42 209.82-64.89 60.11-76.09 70.49-142.21-153.48c-0.24 4.79-0.44 9.59-0.44 14.44 0 160.33 115.86 314.94 276.22 314.94 47.99 0 79.94 0 147.23-56.96 46.45-51.46 74.74-119.63 74.74-194.41-0.01-160.33-130-290.3-290.35-290.3z" fill="#9CD5E4" p-id="15888"></path><path d="M801.86 950.09c-37.61 0-75.21-14.24-103.94-42.76l-190.06-188.7c-32.14 10.01-65.47 15.07-99.37 15.07-184.62 0-334.82-150.2-334.82-334.82 0-53.85 12.49-105.4 37.11-153.19l22.09-42.85 209.87 226.51 96.56-89.46-210.6-227.31 42.96-19.28c43.26-19.41 89.3-29.25 136.83-29.25 184.63 0 334.83 150.2 334.83 334.83 0 40.29-7.07 79.5-21.04 116.85l183.53 182.2c57.72 57.33 58.07 150.92 0.75 208.65-28.79 29-66.75 43.51-104.7 43.51zM524.99 640.36l220.58 218.98c31.26 31.06 81.97 30.86 113.02-0.41 31.05-31.26 30.86-81.97-0.41-113.02L641.83 531.12l9.79-21.43c15.98-34.98 24.09-72.26 24.09-110.81 0-147.35-119.87-267.22-267.22-267.22-21.45 0-42.51 2.51-62.99 7.49l189.36 204.39L339.09 524.9 152.16 323.16c-7.24 24.39-10.88 49.71-10.88 75.72 0 147.34 119.87 267.21 267.21 267.21 33 0 65.32-6.01 96.07-17.85l20.43-7.88z" fill="#233649" p-id="15889"></path> </svg> 工具 </li> <li data-page="ziyou"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M512 512m-512 0a512 512 0 1 0 1024 0 512 512 0 1 0-1024 0Z" fill="#69ADF4" p-id="22213"></path><path d="M613.761496 745.452845h122.876808c32.906875 0 58.695233-28.008754 55.661543-60.455907l-30.990566-331.448767C759.408137 333.211037 742.176524 317.655495 721.550466 317.655495H613.761496v427.79735z" fill="#FFFFFF" opacity=".4" p-id="22214"></path><path d="M304.475186 277.749026c-20.698687 0-37.963024 15.825309-39.757219 36.446578l-32.247619 370.544337c-2.842139 32.643492 22.890351 60.712904 55.65835 60.712904h338.738881c32.72969 0 58.449409-28.007956 55.666332-60.618725l-31.617895-370.571473C649.152948 293.613443 631.878235 277.749026 611.15321 277.749026h-62.321135v51.479345c0 50.47051-40.915305 91.385814-91.385815 91.385815s-91.385814-40.915305-91.385814-91.385815V277.749026h-61.58526z" fill="#FFFFFF" p-id="22215"></path><path d="M410.755691 277.749026v51.479345c0 25.786762 20.903807 46.690569 46.690569 46.690569s46.690569-20.903807 46.690569-46.690569V277.749026h-93.381138z" fill="#FFFFFF" p-id="22216"></path> </svg> 自由 </li> <li data-page="ziliao"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M696.32 81.92a40.96 40.96 0 0 1 40.96 40.96v655.36a40.96 40.96 0 0 1-40.96 40.96H204.8a40.96 40.96 0 0 1-40.96-40.96V122.88a40.96 40.96 0 0 1 40.96-40.96h491.52zM204.8 0a122.88 122.88 0 0 0-122.88 122.88v655.36a122.88 122.88 0 0 0 122.88 122.88h491.52a122.88 122.88 0 0 0 122.88-122.88V122.88a122.88 122.88 0 0 0-122.88-122.88H204.8z" fill="#4E4E4E" p-id="24788"></path><path d="M901.12 245.76a40.96 40.96 0 0 1 40.96 40.96v573.44c0 90.43968-73.23648 163.84-163.75808 163.84H368.64a40.96 40.96 0 1 1 0-81.92h409.68192A81.87904 81.87904 0 0 0 860.16 860.16V286.72a40.96 40.96 0 0 1 40.96-40.96zM245.76 245.76a40.96 40.96 0 0 1 40.96-40.96h327.68a40.96 40.96 0 1 1 0 81.92H286.72a40.96 40.96 0 0 1-40.96-40.96zM245.76 450.56a40.96 40.96 0 0 1 40.96-40.96h327.68a40.96 40.96 0 1 1 0 81.92H286.72a40.96 40.96 0 0 1-40.96-40.96z" fill="#4180FF" p-id="24789"></path><path d="M245.76 655.36a40.96 40.96 0 0 1 40.96-40.96h327.68a40.96 40.96 0 1 1 0 81.92H286.72a40.96 40.96 0 0 1-40.96-40.96z" fill="#4180FF" p-id="24790"></path> </svg> 资料 </li> <li data-page="jubao"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M791.057 201.71c40.66 0 66.583 21.367 66.583 32.553v437.674c0 11.155-25.923 32.522-66.583 32.522H620.311l-9.238 2.262-3.488 0.848-11.375 2.797-10.086 6.001-3.205 1.917-9.3 5.562-7.448 7.855-55.868 58.853-62.75-62.372-6.755-6.441-7.038-4.525-9.898-6.002-10.024-3.142-11.5-3.613H232.912c-40.597 0-66.52-21.367-66.52-32.522V234.263c0-11.186 25.923-32.553 66.52-32.553h558.145m0-78.555H232.88c-80.125 0-145.074 49.74-145.074 111.108v437.674c0 61.241 64.949 111.076 145.074 111.076h157.392l1.068 0.346 0.817 0.534L508.544 899.65l3.456 1.194 3.08-1.226 108.059-113.84 3.205-1.918 3.488-0.848h161.225c80.157 0 145.137-49.835 145.137-111.076V234.263c0-61.367-64.98-111.108-145.137-111.108z" fill="#4796E3" p-id="26760"></path><path d="M557.185 608.685c0 17.847-14.423 32.301-32.302 32.301h-29.6c-17.847 0-32.332-14.454-32.332-32.301v-29.6a32.364 32.364 0 0 1 32.333-32.332h29.599c17.848 0 32.302 14.485 32.302 32.333v29.599z m-94.266-347.368l-22.246 27.494 47.132 206.85h43.205l48.421-210.778-22.246-23.566z" fill="#FFC001" p-id="26761"></path> </svg> 举报 </li> <li data-page="guanyu"> <svg class="nav-icon" viewBox="0 0 1024 1024"> <path d="M476.9536 314.368a36.48 36.48 0 1 1 36.48-36.48 36.48 36.48 0 0 1-36.48 36.48z m0 97.28a24.32 24.32 0 0 1 24.32 24.32v389.12a24.32 24.32 0 0 1-48.64 0v-389.12a24.32 24.32 0 0 1 24.32-24.32zM511.1296 998.4c-134.1696 0-280.6784-30.0544-368.128-119.168a22.7072 22.7072 0 0 1-4.8896-4.6336 2.4064 2.4064 0 0 1-0.256-0.256 23.9104 23.9104 0 0 1-5.12-14.464 24.2432 24.2432 0 0 1 24.1152-24.32 23.6288 23.6288 0 0 1 19.5584 10.88l0.8448-0.6144a431.1552 431.1552 0 0 0 308.3264 129.5872 438.4768 438.4768 0 1 0-409.9072-294.4 25.7536 25.7536 0 0 1 1.9456 20.992 24.1408 24.1408 0 0 1-29.5424 17.2032 23.6544 23.6544 0 0 1-12.8-9.216l-0.256 0.1792c0-0.256-0.1536-0.512-0.256-0.768a23.808 23.808 0 0 1-4.1984-12.6208 482.1248 482.1248 0 0 1-27.4944-159.232c0-268.6208 241.6384-512 508.1344-512A486.4256 486.4256 0 0 1 511.1296 998.4zM103.6032 759.68a26.368 26.368 0 0 1 17.7664 23.3984 24.6784 24.6784 0 0 1-22.7584 24.0384c40.6528-2.4064-36.1216 13.2352-24.5504-30.2592a24.0896 24.0896 0 0 1 29.5424-17.1776z" fill="#48BCF5" p-id="27775"></path><path d="M512.0256 1024a509.6704 509.6704 0 0 1-363.52-152.3712 24.5248 24.5248 0 0 1-5.12-4.8896l-0.3072-0.256a25.0368 25.0368 0 0 1-5.5552-15.36 25.6 25.6 0 0 1 25.6-25.6 25.1648 25.1648 0 0 1 20.7616 11.4432l0.896-0.6656a465.3824 465.3824 0 1 0-107.776-173.3632 27.008 27.008 0 0 1 2.048 22.0928 25.6 25.6 0 0 1-31.36 18.0992 25.1648 25.1648 0 0 1-13.5936-9.7024l-0.2816 0.2048c0-0.256-0.1536-0.5376-0.256-0.8192a25.1392 25.1392 0 0 1-4.4544-13.2864A503.4496 503.4496 0 0 1 0.0256 512a512 512 0 1 1 512 512zM106.7776 745.7536a27.7504 27.7504 0 0 1 18.8416 24.6528 26.112 26.112 0 0 1-24.1408 25.2928c43.136-2.56-38.4 13.9264-26.0352-31.8464a25.6 25.6 0 0 1 31.3344-18.0992zM513.0496 268.8a38.4 38.4 0 1 1 38.4-38.4 38.4 38.4 0 0 1-38.4 38.4z m0 102.4a25.6 25.6 0 0 1 25.6 25.6v409.6a25.6 25.6 0 0 1-51.2 0v-409.6a25.6 25.6 0 0 1 25.6-25.6z" fill="#4076FE" p-id="27776"></path> </svg> 关于 </li> <!-- 其他导航项 --> </ul> </div> <div id="content"></div> </div> <script src="/js/scripts.js"></script> </body> </html> JS文件 document.addEventListener("DOMContentLoaded", function() { var navItems = document.querySelectorAll('#nav li'); navItems.forEach(function(item) { item.addEventListener('click', function(event) { event.preventDefault(); // 防止默认行为 var page = this.getAttribute('data-page'); loadPage(page); updateURL(page); // 执行特定于页面的JavaScript代码 if (page === 'home') { executeHomePageScript(); } else if (page === 'price') { executePricingPageScript(); } }); }); function loadPage(pageName) { var xhr = new XMLHttpRequest(); xhr.open("GET", pageName + ".html", true); xhr.onreadystatechange = function() { if (xhr.readyState == 4 && xhr.status == 200) { document.getElementById('content').innerHTML = xhr.responseText; } }; xhr.send(); } function updateURL(pageName) { var baseUrl = window.location.origin; // 获取当前域名 var newUrl = ''; switch (pageName) { case 'home': newUrl = baseUrl; break; case 'price': newUrl = baseUrl + '/' + pageName; break; // 添加其他页面的URL映射 default: newUrl = baseUrl; } window.history.pushState({page: pageName}, '', newUrl); } function executeHomePageScript() { console.log("首页特定的JavaScript代码正在执行"); // 示例:添加一个按钮点击事件 const button = document.createElement('button'); button.innerText = '点击我'; button.onclick = function() { alert('按钮被点击了!'); }; document.getElementById('content').appendChild(button); } function executePricingPageScript() { console.log("价格页面特定的JavaScript代码正在执行"); // 在这里编写价格页面特定的JavaScript代码 } // 默认加载首页并执行相应的脚本 loadPage('home'); executeHomePageScript(); // 监听浏览器的前进后退事件 window.onpopstate = function(event) { if (event.state && event.state.page) { loadPage(event.state.page); if (event.state.page === 'home') { executeHomePageScript(); } else if (event.state.page === 'price') { executePricingPageScript(); } } }; // 检查初始URL以确保正确加载页面 var path = window.location.pathname; var pageName = path.split('/').pop(); if (pageName === '') { loadPage('home'); executeHomePageScript(); } else if (pageName === 'price') { loadPage(pageName); executePricingPageScript(); } }); CSS文件 #container { display: flex; } #sidebar { width: 200px; background-color: #8da38e6c; /* 设置背景颜色为灰色 */ height: 100vh; } #nav { list-style-type: none; padding: 0; margin: 0; } #nav li { padding: 15px; /* 增加内边距以调整项目内部间距 */ margin-bottom: 10px; /* 增加外边距以调整项目之间的间距 */ cursor: pointer; display: flex; align-items: center; border-radius: 4px; transition: background-color 0.3s ease; } #nav li:hover { background-color: #ddd; } #nav li svg.nav-icon { margin-right: 8px; width: 16px; height: 16px; } #content { flex-grow: 1; padding: 20px; }
代码心得
# WEB
# JS
# 查询工具
潼语
3月12日
0
11
0
2024-11-13
牛奶咖啡相关代码
牛奶咖啡相关代码 前言 记录编写牛奶咖啡软件的相关代码,方便后续自己修改更新改进 相关代码 {collapse-item label="游戏更新标识" close} 说明:获取游戏更新内容的标识,以达到自动发布游戏更新内容,代码如下: private async void 更新标识() { string url = "http://rc.leeuu.com/data/js/rcdef01.js";//浪漫庄园更新地址 using HttpClient client = new HttpClient(); string pagecontent = await client.GetStringAsync(url); string pattern = @"news,(.*?),"; Match match = Regex.Match(pagecontent, pattern); if (match.Success) { string extractedContent = match.Groups[1].Value; Console.WriteLine(extractedContent); string url_更新内容 = "http://rc.leeuu.com/data/news/" + extractedContent + ".htm"; using HttpClient client1 = new HttpClient(); string pagecontent1 = await client1.GetStringAsync(url_更新内容); HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(pagecontent1); HtmlNode 内容 = doc.DocumentNode.SelectSingleNode("//div[@id='right']");//获取更新内容的相关信息 if (内容 != null) { Console.WriteLine(内容.InnerHtml); string 正文 = 内容.InnerHtml; //去掉p标签,去掉</strong>标签 正文 = 正文.Replace("<p>", "").Replace("</p>", "").Replace("<strong>", "").Replace("</strong>", "").Replace("<h3>", "").Replace("</h3>", "").Replace("<p style=\"text-align: right;\">", "").Replace(" ", "").Replace("</span>", "").Replace("<span style=\"text-indent: 2em;\">", "").Replace("<br>", "").Replace("<div id=\"qb-sougou-search\" style=\"display: none; opacity: 0;\">\r\n搜索\r\n<p class=\"last-btn\">复制\r\n<iframe src=\"\"></iframe></div>", "").Replace("<span style=\"color: rgb(255, 0, 255);\">", "");//去除无关内容 textBox_首页.Text = 正文; } else { Console.WriteLine("没找到相关内容"); } } else { Console.WriteLine("未找到匹配内容"); } }{/collapse-item} {collapse-item label="获取服务器更新说明" close} 说明:读取服务器内的文本文件获取其中内容,并将获取到的内容显示在指定位置,代码如下: private async Task 历史更新() { string 历史更新_url = "........";//将""中的内容替换为你自己的文本文档地址 try { WebClient client = new WebClient(); string content = client.DownloadString(历史更新_url); // 将换行符替换为TextBox能识别的换行格式 content = content.Replace("\n", "\r\n"); textBox_历史更新.Text = content; } catch (Exception ex) { MessageBox.Show("读取文件出错: " + ex.Message); } }{/collapse-item} {collapse-item label="读取内容到下拉框中" close} 说明:读取服务器中的内容到下拉框中,代码如下: if (comboBox_功能选择.SelectedIndex == 0) { string 搜物_url = ".....";//替换为你的文档位置 try { WebClient client = new WebClient(); string content = client.DownloadString(搜物_url); string[] lines = content.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries); comboBox_查询.Items.Clear(); foreach (string line in lines) { comboBox_查询.Items.Add(line); } } catch (Exception ex) { MessageBox.Show("读取文件出错: " + ex.Message); } }其它的内容类似 {/collapse-item} {collapse-item label="钉钉发送信息函数" close} 说明:钉钉发送信息函数,代码如下: public static class DingDingNotifier { private const string WebhookUrl = "......";//替换为钉钉群内机器人的链接 public static async Task SendMessage(string message) { var client = new HttpClient(); // 使用 markdown 格式并包含 @all var jsonContent = new { msgtype = "markdown", markdown = new { title = "公告", text = $"#### 公告\n{message}\n\n@all" // 注意这里的 @all 标签 }, at = new { atMobiles = new string[] , // 保持为空数组,因为我们使用 @all isAtAll = true // 设置为 true 以 @所有人 } }; var jsonOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }; var content = new StringContent(System.Text.Json.JsonSerializer.Serialize(jsonContent, jsonOptions), Encoding.UTF8, "application/json"); try { HttpResponseMessage response = await client.PostAsync(WebhookUrl, content); if (!response.IsSuccessStatusCode) { Console.WriteLine($"发送消息到钉钉失败。状态码: {response.StatusCode}"); } else { Console.WriteLine("消息发送成功。"); } } catch (Exception ex) { Console.WriteLine($"发送消息到钉钉时出错: {ex.Message}"); } } }{/collapse-item}
代码心得
# 桌面软件
# 代码
潼语
1年前
0
17
0
2024-09-30
Typecho 定时发布每天60秒读懂世界
新闻60秒图片 使用教程 复制下方代码保存到 typecho 的任意一个目录 推荐创建一个 60s 文件夹然后新建一个 index.php的文件 把代码丢进去 代码里面需要修改的地方我已经给你们标注出来了 添加宝塔定时任务 任务类型:访问url 任务名称:随便设置 执行周期:每天 7 小时 30 分钟 脚本内容:就是你的域名/60s 保存完事 要是 https 协议的用宝塔的 shell 命令代码里面写以下代码 #!/bin/bash # 要访问的 HTTPS 链接 url="你的文件链接" # 使用 curl 访问链接 curl -k $url 相关代码信息 <?php $apiUrl = 'http://api.suxun.site/api/sixs?type=json'; $response = file_get_contents($apiUrl); $data = json_decode($response, true); if ($data['code'] === '200') { $dbHost = '127.0.0.1'; $dbUser = '数据库名'; $dbPass = '数据库密码'; $dbName = '数据库名'; $conn = new mysqli($dbHost, $dbUser, $dbPass, $dbName); if ($conn->connect_error) { die("连接失败: ". $conn->connect_error); } $categoryName = '你需要的分类名称'; $sqlGetCategoryId = "SELECT mid FROM `typecho_metas` WHERE `type`='category' AND `name`='$categoryName'"; $result = $conn->query($sqlGetCategoryId); if ($result && $result->num_rows > 0) { $row = $result->fetch_assoc(); $categoryId = $row['mid']; } else { die("无法找到指定分类的 ID。"); } $sqlGetLastCid = "SELECT MAX(CAST(SUBSTRING(cid, 1) AS UNSIGNED)) AS last_cid FROM `typecho_contents`"; $resultLastCid = $conn->query($sqlGetLastCid); $lastCid = 0; if ($resultLastCid && $resultLastCid->num_rows > 0) { $rowLastCid = $resultLastCid->fetch_assoc(); $lastCid = $rowLastCid['last_cid']? $rowLastCid['last_cid'] + 1 : 1; } $date = date('Y 年 n 月 j 日,l'); $title = $date. ',每日 60 秒读懂世界'; $content = '<img src="'.$data['head_image'].'"><br>'; foreach ($data['news'] as $newsItem) { $content.= $newsItem.'<br>'; } $content.= '<br>'.$data['weiyu']; $tags = '每日 60 秒'; $cid = $lastCid; $slug = date('Ymd'); $sqlInsertPost = "INSERT INTO `typecho_contents` (`cid`, `title`, `slug`, `created`, `modified`, `text`, `order`, `authorId`, `template`, `type`, `status`, `password`, `commentsNum`, `allowComment`, `allowPing`, `allowFeed`, `parent`, `views`, `agree`) VALUES ('$cid', '$title', '$slug', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), '$content', '0', '1', NULL, 'post', 'publish', NULL, '0', '1', '1', '1', '0', '1', '0')"; if ($conn->query($sqlInsertPost) === TRUE) { $lastInsertId = $conn->insert_id; $sqlInsertRelation = "INSERT INTO `typecho_relationships` (`cid`, `mid`) VALUES ($lastInsertId, $categoryId)"; if ($conn->query($sqlInsertRelation) === TRUE) { echo "文章发布成功!"; } else { echo "Error inserting relationship: ". $conn->error; } } else { echo "Error inserting post: ". $sqlInsertPost. "<br>". $conn->error; } $conn->close(); } else { echo '获取 API 数据失败。'; } ?> 修改上述代码中文标注地方,修改为你自己的信息
代码心得
潼语
1年前
0
10
0
2024-09-19
C#免注册调用大漠插件
前言 免注册调用大漠插件,实际上是使用 dmreg.dll 来配合实现,这个文件有 2 个导出接口 SetDllPathW 和 SetDllPathA。 SetDllPathW 对应 unicode,SetDllPathA 对应 ascii 接口。 一、下载大漠插件 下载地址 大漠插件 解压完成后,如下图所示: 大漠插件图片 二、生成大漠类库 打开 大漠类库生成工具 文件夹,如下图所示: 大漠插件图片 打开 大漠类库生成工具 v28.0.exe 文件,如下图所示: 大漠插件图片 将 dm\7.2434\dm.dll 拖到 大漠类库生成工具 里面,如下图所示: 大漠插件图片 类名选择使用自定义类名,指定类名输入 DmSoftCustomClassName(这里只是示例,你可以输入你喜欢的名字,如:abcde、aabbc、abab 等),如下图所示: 大漠插件图片 点击生成按钮,如下图所示: 大漠插件图片 打开 \7.2434\Output\C# 文件夹,可以看到生成的结果,如下图所示: 大漠插件图片 生成的 obj.cs 即是使用在 C# 平台下的类库封装,稍后在 C# 免注册调用大漠插件的示例中会用到。 三、创建控制台应用程序 注意:我这里创建的是 .NET Core 8.0 的窗口应用程序,你也可以创建你喜欢的。 3.1 引入大漠插件 dll 在项目中创建 libs 文件夹,用于放置大漠插件的 dll,如下图所示: 大漠插件图片 dm.dll 在 \7.2434 文件夹下,如下图所示: 大漠插件图片 DmReg.dll 在 免注册\不注册调用dm.dll的方法 v15.0 文件夹下,如下图所示: 大漠插件图片 设置 dll 属性 复制到输出目录 为 始终复制: 在 dm.dll 上单击鼠标右键,选择 属性; 在属性面板中,“复制到输出目录”选项,选择“始终复制”; 在 DmReg.dll 也重复上面的操作。 大漠插件图片 3.2 引入大漠类库 在项目中创建 DmSoft 文件夹,用于放置大漠类库。 将之前生成的大漠类库(obj.cs)复制到项目中的 DmSoft 文件夹,并改名为 DmSoftCustomClassName(可以改名,也可以不改名,还可以改成任意名,你喜欢就好……),如下图所示: 大漠插件图片 3.3 创建 Resources 文件夹 在项目中创建 Resources 文件夹,用于放置大漠插件使用到的资源,比如图片、字库等,如下图所示: 大漠插件图片 3.4 创建大漠插件配置类 在项目中创建 Configs 文件夹,并在 Configs 中创建 DmConfig 类,用于设置大漠插件用到的常量。 DmConfig.cs namespace DmSoftTestConsoleApp.Configs { /// <summary> /// 大漠插件配置 /// </summary> public class DmConfig { /// <summary> /// 大漠插件免注册 DmReg.dll 路径 /// </summary> public const string DmRegDllPath = @"./libs/DmReg.dll"; /// <summary> /// 大漠插件 dm.dll 路径 /// </summary> public const string DmClassDllPath = @"./libs/dm.dll"; /// <summary> /// 大漠插件注册码 /// </summary> public const string DmRegCode = ""; /// <summary> /// 大漠插件版本附加信息 /// </summary> public const string DmVerInfo = ""; /// <summary> /// 大漠插件全局路径,设置了此路径后,所有接口调用中,相关的文件都相对于此路径. 比如图片,字库等. /// </summary> public const string DmGlobalPath = @"./Resources"; } }3.5 创建 C# 免注册调用大漠插件类 namespace DmSoftTestConsoleApp.Configs { /// <summary> /// 大漠插件配置 /// </summary> public class DmConfig { /// <summary> /// 大漠插件免注册 DmReg.dll 路径 /// </summary> public const string DmRegDllPath = @"./libs/DmReg.dll"; /// <summary> /// 大漠插件 dm.dll 路径 /// </summary> public const string DmClassDllPath = @"./libs/dm.dll"; /// <summary> /// 大漠插件注册码 /// </summary> public const string DmRegCode = ""; /// <summary> /// 大漠插件版本附加信息 /// </summary> public const string DmVerInfo = ""; /// <summary> /// 大漠插件全局路径,设置了此路径后,所有接口调用中,相关的文件都相对于此路径. 比如图片,字库等. /// </summary> public const string DmGlobalPath = @"./Resources"; } }在 DmSoft 文件夹创建 RegisterDmSoft 类,用于实现 C# 免注册调用大漠插件。 RegisterDmSoft.cs using System.Runtime.InteropServices; using DmSoftTestConsoleApp.Configs; namespace DmSoftTestConsoleApp.DmSoft { /// <summary> /// 免注册调用大漠插件 /// </summary> public static class RegisterDmSoft { // 不注册调用大漠插件,实际上是使用 dmreg.dll 来配合实现,这个文件有 2 个导出接口 SetDllPathW 和 SetDllPathA。 SetDllPathW 对应 unicode,SetDllPathA 对应 ascii 接口。 [DllImport(DmConfig.DmRegDllPath)] private static extern int SetDllPathA(string path, int mode); /// <summary> /// 免注册调用大漠插件 /// </summary> /// <returns></returns> public static bool RegisterDmSoftDll() { var setDllPathResult = SetDllPathA(DmConfig.DmClassDllPath, 1); if (setDllPathResult == 0) { // 加载 dm.dll 失败 return false; } return true; } } }注意,在 .NET Core 中,无法使用 64 位进程加载 32 位 dll。解决方法是将程序设置为 32 位的。 大漠插件图片 四、测试 4.1 测试 C# 免注册调用大漠插件 在 Program 类中编写测试代码。 Program.cs using System; using DmSoftTestConsoleApp.DmSoft; namespace DmSoftTestConsoleApp { class Program { static void Main(string[] args) { if (Environment.Is64BitProcess) { Console.WriteLine("这是 64 位程序"); Console.WriteLine("按任意键结束程序"); Console.ReadKey(); return; } // 免注册调用大漠插件 var registerDmSoftDllResult = RegisterDmSoft.RegisterDmSoftDll(); Console.WriteLine($"免注册调用大漠插件返回:{registerDmSoftDllResult}"); Console.WriteLine("按任意键结束程序"); Console.ReadKey(); } } }4.2 测试 Capture 方法 修改 Program 类。 Program.cs using System; using System.IO; using DmSoftTestConsoleApp.Configs; using DmSoftTestConsoleApp.DmSoft; namespace DmSoftTestConsoleApp { class Program { static void Main(string[] args) { if (Environment.Is64BitProcess) { Console.WriteLine("这是 64 位程序"); Console.WriteLine("按任意键结束程序"); Console.ReadKey(); return; } // 免注册调用大漠插件 var registerDmSoftDllResult = RegisterDmSoft.RegisterDmSoftDll(); Console.WriteLine($"免注册调用大漠插件返回:{registerDmSoftDllResult}"); if (!registerDmSoftDllResult) { throw new Exception("免注册调用大漠插件失败"); } // 创建对象 DmSoftCustomClassName dmSoft = new DmSoftCustomClassName(); // 收费注册 var regResult = dmSoft.Reg(DmConfig.DmRegCode, DmConfig.DmVerInfo); Console.WriteLine($"收费注册返回:{regResult}"); if (regResult != 1) { throw new Exception("收费注册失败"); } // 判断 Resources 是否存在,不存在就创建 if (!Directory.Exists(DmConfig.DmGlobalPath)) { Directory.CreateDirectory(DmConfig.DmGlobalPath); } // 设置全局路径,设置了此路径后,所有接口调用中,相关的文件都相对于此路径. 比如图片,字库等 dmSoft.SetPath(DmConfig.DmGlobalPath); // 抓取指定区域(x1, y1, x2, y2)的图像,保存为file(24位位图) var captureResult = dmSoft.Capture(0, 0, 2000, 2000, "screen.bmp"); Console.WriteLine($"Capture 返回:{captureResult}"); if (captureResult != 1) { throw new Exception("Capture 失败"); } Console.WriteLine("按任意键结束程序"); Console.ReadKey(); } } }运行程序,dmSoft.Reg() 方法返回 -2(进程没有以管理员方式运行)。 五、在 VS 中设置程序以管理员身份运行 添加应用程序清单文件到项目中(项目 → 右键 → 添加 → 新建项 → 应用程序清单文件),如下图所示: 大漠插件图片 打开 app.manifest 文件,将 requestedExecutionLevel 元素的 level 属性设置为 highestAvailable。 也就是将 <requestedExecutionLevel level="asInvoker" uiAccess="false" />改为 <requestedExecutionLevel level="highestAvailable" uiAccess="false" />按 F5 运行程序,VS 将提示“此任务要求应用程序具有提升的权限。”,点击“使用其他凭据重新启动(R)”,如下图所示: 大漠插件图片 VS 重新启动之后,按 F5 运行程序,screen.bmp 图片保存到 Resources 文件夹中。 六、源码地址 源码地址:https://github.com/astrid9527... 七、总结 本文已经完整地介绍了如何使用 C# 免注册调用大漠插件的方法,解决方案的结构如下图所示: 大漠插件图片 需要注意的地方有如下几点 在 .NET Core 中 LoadLibrary 无法使用 64 位进程加载 32 位 dll。解决方法是将程序设置为 32 位的。 dm.dll 和 DmReg.dll 需要设置为始终复制到输出目录。 注意检查 SetPath(path) 方法中的 path 是否存在,不存在就创建。 在 VS 中设置程序以管理员身份运行。
代码心得
潼语
1年前
0
16
0
2024-08-21
浪漫庄园公告自动发布
前言 当前脚本使用的开发语言是Python,功能是通过脚本的运行获取浪漫庄园每次游戏更新后的更新内容,并且通过钉钉api将内容实时发送到钉钉群内。 教程 第一步 在代码开头将编码设置为“gbk” # -*- coding: gbk -*-设置这一步是防止后续出现乱码的问题 第二步 需要添加相关的扩展 from sqlite3 import Timestamp import requests import chardet from bs4 import BeautifulSoup from datetime import datetime import mysql.connector import re其中需要安装的有:requests、bs4、mysql 第三步 数据库配置 # MySQL数据库配置 db_config = { 'user': 'user', //数据库用户名 'password': 'password', //数据库密码 'host': 'ip', //数据库IP地址 'database': 'database', //数据库名 'raise_on_warnings': True # 要保存的表名 table_name = 'huancun' //将“huancun”换成自己数据库中定义的表名 } 第四步 获取网页中需要的内容 def format_current_date(): # 获取当前日期 now = datetime.now() # 提取年份的后两位 year_last_two = str(now.year)[-2:] # 提取月份和日期的两位数字 month_two = str(now.month).zfill(2) # zfill确保总是两位数字 day_two = str(now.day).zfill(2) # 同上 # 组合成字符串并加上01 formatted_date = year_last_two + month_two + day_two + '01' return formatted_date def get_webpage_text_content(url_template): try: # 假设URL模板是 http://rc.leeuu.com/data/news/{date}.htm formatted_date = format_current_date() url = url_template.format(date=formatted_date) #url = url_template.format(date='24062601') response = requests.get(url) # 尝试检测编码(如果响应内容不是UTF-8) raw_data = response.content if not response.encoding.lower() == 'utf-8': result = chardet.detect(raw_data) encoding = result['encoding'] content = raw_data.decode(encoding, errors='ignore') # 使用检测到的编码解码 else: content = response.text # 如果已经是UTF-8,则直接使用text # 确保请求成功 if response.status_code == 200: # 使用BeautifulSoup解析HTML soup = BeautifulSoup(content, 'html.parser') # 提取所有文本内容(包括段落、标题等) text_content1 = soup.get_text(strip=True, separator='\n') # strip=True 去除多余空白,separator='\n' 以换行符分隔文本块 text_content = re.sub(r'(搜索.*\n复制.*)', '', text_content1, flags=re.DOTALL | re.MULTILINE) return text_content else: return f"Failed to retrieve the webpage. Status code: {response.status_code}" #报告网页错误 except requests.RequestException as e: return f"Oops: Something Error {e}" except UnicodeDecodeError as e: return f"Error decoding the webpage: {e}" 第五步 # 发送钉钉文本消息的函数 def send_dingtalk_text_message(content, webhook_url): headers = { 'Content-Type': 'application/json', 'Charset': 'UTF-8', } message = { "msgtype": "text", "text": { "content": content } } try: response = requests.post(webhook_url, json=message, headers=headers) response.raise_for_status() # 如果请求失败,抛出HTTPError异常 print("DingTalk text message sent successfully.") except requests.RequestException as e: print(f"Error sending DingTalk text message: {e}") #send_dingtalk_text_message("今日暂无更新", DINGTALK_WEBHOOK_URL) # 钉钉Webhook的URL DINGTALK_WEBHOOK_URL = 'https://oapi.dingtalk.com/robot/send?access_token=XXXX' //将XXXX替换为自己钉钉群内自定义机器人中的数据 # 使用URL模板 url_template = "http://rc.leeuu.com/data/news/{date}.htm" content = get_webpage_text_content(url_template)第六步 连接数据库并且添加获取到的内容进数据库,同时向钉钉群内发送消息 # 假设这是你从某个数据源获取的新内容及其相关信息 if "404" in content: new_content = "今日无更新内容。" else: new_content = content new_key_value = format_current_date() timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S') # 获取当前时间戳 # 连接到MySQL数据库 cnx = mysql.connector.connect(**db_config) cursor = cnx.cursor() # 定义表名和字段 table_name = "huancun" key_field = 'key' # 替换为你的唯一键字段名 content_field = 'content' # 内容字段名 timestamp_field = 'timestamp' # 时间戳字段名 # 执行查询 query = f"SELECT {content_field} FROM {table_name} WHERE `{key_field}` = %s" cursor.execute(query, (new_key_value,)) # 使用参数化查询来防止SQL注入 # 获取查询结果 result = cursor.fetchone() # 因为是根据主键查询,所以预期只返回一个结果 # 检查 result 是否存在 if result: content1 = result[0] if content1 == new_content: print("当前数据未更新!") else: # 使用 f-string 构建 SQL 查询 insert_query = f""" INSERT INTO `{table_name}` (`{key_field}`, `{content_field}`, `{timestamp_field}`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `{content_field}` = VALUES({content_field}), `{timestamp_field}` = VALUES({timestamp_field}) """ try: cursor.execute(insert_query, (new_key_value, new_content, timestamp)) cnx.commit() print("新内容已保存到数据库,或已存在的记录已更新。") if "404" not in new_content: send_dingtalk_text_message(new_content, DINGTALK_WEBHOOK_URL) except Exception as e: print(f"发生错误:{e}") else: # 如果没有找到记录,直接插入新数据 insert_query = f""" INSERT INTO `{table_name}` (`{key_field}`, `{content_field}`, `{timestamp_field}`) VALUES (%s, %s, %s) ON DUPLICATE KEY UPDATE `{content_field}` = VALUES({content_field}), `{timestamp_field}` = VALUES({timestamp_field}) """ try: cursor.execute(insert_query, (new_key_value, new_content, timestamp)) cnx.commit() print("新内容已保存到数据库,或已存在的记录已更新。") if "404" not in new_content: send_dingtalk_text_message(new_content, DINGTALK_WEBHOOK_URL) except Exception as e: print(f"发生错误:{e}") # 关闭游标和连接 cursor.close() cnx.close()代码到此完毕,后续根据实际情况会进行优化删减,使代码运行更加方便 第七步 最后一步将文件上传到服务器上,添加定时任务中的shell脚本填写以下代码: sudo -u root bash -c '#!/bin/bash . /etc/profile . ~/.bash_profile /usr/bin/XX /XXX/XXX/浪漫庄园公告.py'
代码心得
潼语
1年前
0
36
0