当前位置:网站首页>PIXIV Gizmo

PIXIV Gizmo

2022-06-24 21:12:00 The smell of tobacco

Preface

Recently I saw a big man , Open source a small blog plug-in , Address . Can be pixiv The daily list of the website is put in the blog sidebar . It looks cool . So I also introduced it into my blog . I would like to express my thanks to the boss .

But in use , It is often encountered that the access is very slow , After checking, I found , The big guy's server is set up in Korea , No wonder access is slow , It's all international bandwidth .

therefore , I just built one in Beijing , If necessary, it can be introduced by itself . The effect can be Home page see . Address : https://fun.hujingnb.com/pixiv/i

Use

I'm using WordPress, So WordPress For example , Please handle other situations by yourself . The click effect of the current image is to open the original image .

Add sidebar HTML Control , Content (iframe Please modify ):

<iframe src="https://fun.hujingnb.com/pixiv/i" frameborder="0" style="width:300px; height:400px;" ></iframe>

in addition , I added a few requested GET Parameters , It is used for customization of small partners in need .

  • interval: Page rotation duration ( millisecond ). Default 5000
  • bg: Background color , Default transparent
  • w: Image width . Default 300
    • Because many of the pictures on the daily list exceed 1MB, Therefore, the image is compressed , Can improve access speed .
    • Optional value : 100, 200, 300, 400, 500.
  • limit: Ranking range of rotation training . Default 1,50
    • 1,50 Show rankings for 1-50 Pictures of the
    • The biggest ranking 100, For the time being 100 It should be enough , So we only took the Japanese list top 100

Subsequent updates

principle

At the beginning , I was thinking about the project down Come down , Just configure it to run , however , After reading the source code , I find that I can't use many functions of others , I just need a crawler and a presentation page . I just wrote a .

The implementation is very simple , Here is a brief introduction , No more open source , There are only a few lines .

A presentation page , from oss Read pictures from the fixed path of the . Like ranking 1 Of , Path is : pixiv/1.jpg.

A script that executes regularly every day , Download and overwrite the latest pictures oss File contents of . To save money , When the download is complete ecs release . Specific to see Alibaba cloud schedules tasks and automatically releases them . meanwhile , Because the page uses cdn Read the picture , So after downloading , To refresh the next cdn cache .

be without , That's all . Of course , Now there are still some problems , such as :

  • If the scheduled script is executed , The daily leaderboard has not been refreshed , Lack of retry mechanism
  • The page can only read pictures url, Unable to read more information , Lack of data communication
  • If there is no picture of a ranking on that day , The page doesn't know , There will still be demonstrations . ( Because it is a file overwrite , You can still read old files )
  • wait

However, the current requirements are not high , These problems are tolerable .

原网站

版权声明
本文为[The smell of tobacco]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211318416174.html