Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
spla
spla
@spla@mastodont.cat  ·  activity timestamp 2 weeks ago

Mastodon no permet entrar en tendència als enllaços a tuts del fedivers.
A #appy es mostraven en les tendències però he tingut una bona idea per evitar-ho, tant l'usuari que ha publicat el tut com el seu domini ja estan desats en la base de dades abans d'obtenir les meta dades Open Graph per a generar les "preview cards". Un petit filtre verifica que el domini no hi sigui en la taula accounts abans de processar les metadades del enllaç.

for url in urls:
url_domain = urlparse.urlparse(url).netloc
is_fediverse = await db.is_fediverse_domain(url_domain, status.get('account_id'))
if not is_fediverse:
fn @Er whe URL
| headers = {'User-Agent': 'appy - httpx'}
1215V/ 8
async with httpx.AsyncClient(timeout=3.0) as client:
response = await client.get(url, headers=headers)
# Analize HTML content
soup = BeautifulSoup(response.content, 'html.parser')
# Search OpenGraph data
for tag in soup.find_all('meta'):
if tag.get('property') and tag.get('property').startswith('og:'):
og_tags[tag.get('property')] = tag.get('content')
for url in urls: url_domain = urlparse.urlparse(url).netloc is_fediverse = await db.is_fediverse_domain(url_domain, status.get('account_id')) if not is_fediverse: fn @Er whe URL | headers = {'User-Agent': 'appy - httpx'} 1215V/ 8 async with httpx.AsyncClient(timeout=3.0) as client: response = await client.get(url, headers=headers) # Analize HTML content soup = BeautifulSoup(response.content, 'html.parser') # Search OpenGraph data for tag in soup.find_all('meta'): if tag.get('property') and tag.get('property').startswith('og:'): og_tags[tag.get('property')] = tag.get('content')
for url in urls: url_domain = urlparse.urlparse(url).netloc is_fediverse = await db.is_fediverse_domain(url_domain, status.get('account_id')) if not is_fediverse: fn @Er whe URL | headers = {'User-Agent': 'appy - httpx'} 1215V/ 8 async with httpx.AsyncClient(timeout=3.0) as client: response = await client.get(url, headers=headers) # Analize HTML content soup = BeautifulSoup(response.content, 'html.parser') # Search OpenGraph data for tag in soup.find_all('meta'): if tag.get('property') and tag.get('property').startswith('og:'): og_tags[tag.get('property')] = tag.get('content')
  • Copy link
  • Flag this post
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-alpha.44 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct