显示标签为“python”的博文。显示所有博文
显示标签为“python”的博文。显示所有博文

2024年5月10日星期五

[youtube-dl]Blocked?

 Just want to confirm if there is any newer version for YouTube-dl, unfortunately, it was blocked by de court...


It was shown that [Access denied] to yt-dl.org due to a ruling of the Hamburg Regional Court.

Access to this website is blocked.


So, we still have another way.

https://github.com/ytdl-org/youtube-dl

But it seems that it stopped development since 2021.

ーーーーーーーーーーーーーーーSuper beautiful seperate lineーーーーーーーーーーーー

After asked Google, I found the below repository.

yt_dlp

We can make some change on script to work on yt_dlp rather than Youtube_DL.

2024年4月15日星期一

[Python]Use Python to send form data to page

 Consider to request a form URL to get the site accept the data.

import requests # Define the form data form_data = { 'name': 'G X', 'email': 'gx@gx.com' } # Send a POST request with the form data response = requests.post('http://gx.com/submit', data=form_data) # Check if the request was successful (status code 200) if response.status_code == 200: print('Form submitted successfully') else: print('Failed to submit the form')


But actually, it won't work for the site I had expected.

Because the site will use a one-time serial session id to identify the request. need to update.

Yes, you are right. this is a tips for company timecard registration automation. 

 

2024年4月11日星期四

[Python]JPG to PNG Python Program

from PIL import Image import os def convert_jpg_to_png(input_folder, output_folder): # 1. Get list up the input folder files jpg_files = [f for f in os.listdir(input_folder) if f.endswith('.jpg')] # 2. Create the output folder if it did not exist os.makedirs(output_folder, exist_ok=True) # 3. Change the JPG to PNG files for jpg_file in jpg_files: jpg_path = os.path.join(input_folder, jpg_file) # Create the PNG file output path png_path = os.path.join(output_folder, os.path.splitext(jpg_file)[0] + '.png') # Change the image img = Image.open(jpg_path) img.save(png_path, 'PNG') if __name__ == "__main__": input_folder = "path" # Define the input path of JPG output_folder = "path" # Define the output path of PNG convert_jpg_to_png(input_folder, output_folder)

Need to get them work on my site...