repl.it
@PYer/

Replit User JSON

Python

No description

fork
loading
Files
  • main.py
  • poetry.lock
  • pyproject.toml
  • requirements.txt
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import bs4, urllib.request, flask

app = flask.Flask('Replit User JSON')

@app.route('/')
def home():
  return 'Assets for rplit module by @PYer'

@app.route('/get', methods=['GET'])
def get_user():
  user = flask.request.args.get('user')
  rdata = flask.request.args.get('data')
  linkprofile = 'https://repl.it/@' + user
  profile = urllib.request.urlopen(linkprofile)
  profile = bs4.BeautifulSoup(profile, 'html.parser')
  try:
    if rdata == 'prof':
      return linkprofile
    elif rdata == 'name':
      return profile.find('h1').text
    elif rdata == 'cycles':
      return profile.find('span', attrs={'title': 'cycles'}).text[1:-1]
    elif rdata == 'bio':
      return profile.find('span', attrs={'class': 'Linkify'}).text
    elif rdata == 'pfp':
      return profile.find('span', attrs={'class': 'profile-icon-xl'})['style'].split('(')[1][1:-2]
    elif rdata == 'langs':
      retstring = ''
      langs = profile.find('div', attrs={'class': 
      'profile-languages'}).find_all('span', attrs={'class': 'jsx-3626407688'})
      for lang in langs:
        retstring += lang.text + '  '
      return str(retstring.strip().split('  '))
  except:
    return 'None'

app.run(port=8080, host='0.0.0.0')