fork download
  1. # your code goes hereimport requests
  2.  
  3. #갤러리명
  4. roffjfl = 'programming'
  5. qjsgh = '406701'
  6.  
  7. comment_nick = 'ㅇㅇ'
  8. comment_pw = "123123"
  9. comment_memo = "테스트"
  10. #httpget
  11. getHeaders ={ "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone iOS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405"}
  12. res = requests.get('http://m...content-available-to-author-only...e.com/view.php?id='+roffjfl+'&no='+qjsgh+'&page=1',headers=getHeaders).text
  13.  
  14. #post데이터 생성
  15.  
  16. #댓글 작성부분의 쿼리 내용만 추린다
  17. st = res.find("<input type=\"hidden\" name=\"mode\"")
  18. ed = res.find("</form>",st)
  19. res = res[st:ed]
  20.  
  21. def ExtractPostData(res, value):
  22. match = "id=\""+value+"\" value=\"";
  23. st = res.find(match);
  24. ed = res.find("\"/>",st);
  25. return res[st+len(match):ed];
  26.  
  27. query = "comment_nick="+comment_nick
  28. query += "&comment_pw="+comment_pw
  29. query += "&comment_memo=" + comment_memo
  30. query += "&mode=comment_nonmember"
  31. query += "&voice_file=" + ExtractPostData(res, "voice_file")
  32. query += "&ukey="
  33. query += "&di_code="
  34. query += "&no=" + qjsgh
  35. query += "&id="+roffjfl
  36. query += "&board_id=" + ExtractPostData(res, "board_id")
  37. query += "&user_no="
  38. query += "&ko_name=" + ExtractPostData(res, "ko_name")
  39. query += "&subject=" + ExtractPostData(res, "subject")
  40. query += "&board_name=" + ExtractPostData(res, "board_name")
  41. query += "&date_time=" + ExtractPostData(res, "date_time")
  42. query += "&ip=" + ExtractPostData(res, "ip")
  43. query += "&best_chk="
  44. query += "&reple_dori_cnt=0"
  45. query = query.encode("UTF-8")
  46.  
  47. #postHeader 정의
  48. postHeaders = {"Host":" m.dcinside.com",
  49. "Connection":" keep-alive",
  50. "Content-Length":len(query),
  51. "Accept":" */*",
  52. "Origin":" http://m...content-available-to-author-only...e.com",
  53. "X-Requested-With":" XMLHttpRequest",
  54. "User-Agent":" Mozilla/5.0 (iPhone; CPU iPhone iOS 5_0_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9A405",
  55. "Content-Type":" application/x-www-form-urlencoded",
  56. "Referer":" http://m...content-available-to-author-only...e.com/view.php?id="+roffjfl+"&no="+qjsgh,
  57. "Accept-Encoding":" gzip,deflate,sdch",
  58. "Accept-Language":"ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4"}
  59.  
  60. httppost = requests.post("http://m...content-available-to-author-only...e.com/_option_write.php",headers=postHeaders, data=query)
  61.  
  62. #리턴값
  63. #{"msg":"1"} 성공
  64. #{"msg":"63"} 도배할수 없습니다.
  65. print(httppost.text)
  66.  
  67.  
Runtime error #stdin #stdout #stderr 0.03s 9440KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 12, in <module>
NameError: name 'requests' is not defined