Skip to content

Instantly share code, notes, and snippets.

@raisinbl
Created October 1, 2023 16:47
Show Gist options
  • Save raisinbl/90e5ad1674af7817e3b68ee902d3a5da to your computer and use it in GitHub Desktop.
Save raisinbl/90e5ad1674af7817e3b68ee902d3a5da to your computer and use it in GitHub Desktop.
#! /opt/miniconda3/bin/python
import requests
from bs4 import BeautifulSoup
tiengruoi = requests.get('https://bit.ly/tiengruoi')
soup = BeautifulSoup(tiengruoi.text, 'html.parser')
# Find all elements with class "cl_item"
cl_items = soup.find_all(class_="cl_item")
urls = [cl_item.find('a').get('href') for cl_item in cl_items][:-2]
# extract domain name
domains = [url.split('/')[2] for url in urls]
domain1 = ""
for domain in domains:
domain1 += '.'.join(domain.split('.')[1:])+','
# load video
domain1 += "player.4shares.live"
# filter elements
elements = [".box-host.box",
".vebo-sp.container",
".mc_padding",
".to-left",".to-right",
".for-desktop.ft-box",
".jw-icon.jw-button-image.jw-button-color.jw-reset"]
filter_elements = [domain1 + "##" + element for element in elements]
# filter gif banner
domain2 = domain1.replace(",","|")
filter_gif_banner = "i.imgur.com/*.gif$image,domain="+domain2
# filter
filter = ["! [SYNTAX] https://help.adblockplus.org/hc/en-us/articles/360062733293",
"||photo2.tinhte.vn/data/attachment-files/$image",
"no-large-media: behind-the-scene false"] +\
filter_elements + [filter_gif_banner]
filter = "\n".join(filter)
# write to file
with open('tiengruoi-filter.txt', 'w') as f:
f.write(filter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment