1. Python / Говнокод #25447

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    import sqlite3
    from bs4 import BeautifulSoup
    import requests, hashlib
    from io import open as iopen
    from urlparse import urlsplit
    
    def md5sum(filename, blocksize=65536):
    	hash = hashlib.md5()
    	with open(filename, "rb") as f:
    		for block in iter(lambda: f.read(blocksize), b""):
    			hash.update(block)
    	return hash.hexdigest()
    
    def parse_image_url(url):
    	html_doc = requests.get(url).text
    	soup = BeautifulSoup(html_doc, 'html.parser')
    	first = soup.find(class_='postContainer')
    	two = first.find_all('img')
    	requests_image(two[1].get('src'))
    
    def unic_check(file_name):
    	check_sum = md5sum(file_name)
    	if c.execute("SELECT * FROM sums WHERE sum = '%s'" % check_sum) != None:
    		cur.close()
    		conn.close()
    		return
    	else:
    		c.execute("INSERT INTO sums VALUES (%s)" % check_sum)
    		c.commit()
    		cur.close()
    		conn.close()
    		return
    
    def requests_image(file_url):
    	suffix_list = ['jpg', 'gif', 'png', 'tif', 'svg',]
    	file_name =  urlsplit(file_url)[2].split('/')[-1]
    	file_suffix = file_name.split('.')[1]
    	i = requests.get(file_url)
    	if file_suffix in suffix_list and i.status_code == requests.codes.ok:
    		with iopen(file_name, 'wb') as file:
    			file.write(i.content)
    	else:
    		return False
    	unic_check(file_name)
    
    def main():
    	Anime_types = ['http://anime.reactor.cc/tag/Anime+%D0%9D%D1%8F%D1%88%D0%B8', 'http://anime.reactor.cc/tag/Anime+Cosplay', 'http://anime.reactor.cc/tag/Anime+%D0%9A%D0%BE%D0%BC%D0%B8%D0%BA%D1%81%D1%8B', 'http://anime.reactor.cc/tag/Anime+Art']
    	global conn
    	global c
    	conn = sqlite3.connect('anime.db')
    	c = conn.cursor()
    	for x in Anime_types:
    		parse_image_url(x)
    		
    if __name__ == "__main__":
    	main()

    marataziat, 13 Марта 2019

    Комментарии (20)
  2. Python / Говнокод #25410

    0

    1. 1
    Мне кажется или в тройке input(str) не дружит в юникоде в str?

    syoma, 26 Февраля 2019

    Комментарии (22)
  3. Python / Говнокод #25409

    +2

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    import ctypes, sys
    if ctypes.windll.shell32.IsUserAnAdmin():
        if __name__ == "__main__":
            main()
    else:
            ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)

    Ав тозапуск с пра вами адми нис тра тора
    Для авто запус ка мы будем исполь зовать сле дующий код:

    Те перь при попыт ке запус тить скрипт вызов будет передан на UAC (если акти‐
    вен) и откро ется новое окно тер минала, где наш код выпол нится от име ни
    адми нис тра тора.
    Ес ли такой вари ант не устра ивает, то всег да мож но вос поль зовать ся
    готовы ми решени ями.
    --------------
    Ксакеп. if __name__ == "__main__" не там стоит, автор не понял что это такое.

    syoma, 26 Февраля 2019

    Комментарии (46)
  4. Python / Говнокод #25350

    −1

    1. 1
    # -- coding: cp866 --

    https://github.com/h4ckzard/wpseyes/blob/master/Windows/wpseyes.py
    В чём это писалось???

    syoma, 02 Февраля 2019

    Комментарии (20)
  5. Python / Говнокод #25345

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    class list(list):
        def __call__(self, *args):
            if len(args) == 0:
                return self[:]
            res = []
            for i in args:
                if type(i) == int:
                    res.append(self[i])
                else:
                    res.append(self(*i) if len(i) != 1 else [[[self(0)]]])
            return res
    
    a = list(map(lambda x: x * x, range(10)))
    
    print(a(1,0,(6,6,(5,4,3,(0)),6),3,2,(),8,))

    Ебат, как добавить список с одним елементом?
    https://ideone.com/Fik3PF

    Rooster, 31 Января 2019

    Комментарии (49)
  6. Python / Говнокод #25324

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    ( '''' )
    ( 3 ) : 'HELLO-FORTH  ." Hello, Forth!" BEGIN REFILL 0= UNTIL ; 'HELLO-FORTH
    echo 'Hello, J!'
    print =: ]
    NB.''')
    print('Hello, Python!')

    1. Forth
    2. J
    3. Python1
    4. Python2
    5. Python3

    Rooster, 24 Января 2019

    Комментарии (17)
  7. Python / Говнокод #25316

    +2

    1. 1
    print(__import__('pickle').loads(b'c__builtin__\ngetattr\n(c__builtin__\nlist\n(c__builtin__\nmap\n(c__builtin__\neval\n(S\'(lambda x:(lambda y:[x.__setitem__(0,(x[0]+2)**0.5),x.__setitem__(1,x[1]*x[0]/2),2/x[1]][2]))\'\ntR((I0\nI1\nltRc__builtin__\nxrange\n(I27\ntRtRtRS\'__getitem__\'\ntR(I-1\ntR.'))

    https://wandbox.org/permlink/sdhWOEIBVq3iiDgF

    j1392184, 18 Января 2019

    Комментарии (19)
  8. Python / Говнокод #25280

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    while True:
        prev_word = next_word
        if next_word.is_empty():
            next_word = random.choice(words)
        else:
            next_word = chain.get_next_word(next_word.root, lambda: Text.Word(''))
    
        suffix = suffix_chain.get_next_word((prev_word.suffix, next_word.root), lambda: '')
        if len(suffix) == 0:
            suffix = next_word.suffix
    
        punct = punct_chain.get_next_word(next_word.root, lambda: '')
    
        if len(output_words) == 0 or output_words[-1].is_ending_word():
            res_word = Text.PunctedWord(next_word.root.capitalize(), suffix, punct)
        else:
            res_word = Text.PunctedWord(next_word.root, suffix, punct)
    
        output_words += [res_word] 
        generated_chars += len(res_word)
        if chars_max_count > 0 and generated_chars > chars_max_count:
            break
        if words_max_count > 0 and len(output_words) > words_max_count:
            break

    Вореции. Генерации. Кобенации. Теперь в энтерпрайз почти ООП-стиле!
    s: https://github.com/gost-gk/vorec-enterprise

    gost, 05 Января 2019

    Комментарии (4)
  9. Python / Говнокод #25181

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    def enum(x):
        globals().update(map(reversed, enumerate(x.split())))
    
    enum("""
        ONE
        TWO
        THREE
        FORTH
    """)

    Forth влияет...

    666_N33D135, 12 Декабря 2018

    Комментарии (30)
  10. Python / Говнокод #25172

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    def is_regular_pay(self, order):
            return order.account is None
    
    
        def is_card_binding(self, order):
            return order.account != None
    
    
    ...
    
    if self.is_regular_pay(order):
                   ...
                    return HttpResponse("OK", status=200)
    
                elif self.is_card_binding(order):
                    ...
                    start_cancel_request(order)
    
                else:
                    get_logger().warn("Unknown successefull operation")
                order.save()

    PashaWNN, 09 Декабря 2018

    Комментарии (3)