# Path: falsy/netboy/curl_result.py
# def curl_result(c):
#     effective_url = c.getinfo(pycurl.EFFECTIVE_URL)
#     primary_ip = c.getinfo(pycurl.PRIMARY_IP)
#     primary_port = c.getinfo(pycurl.PRIMARY_PORT)
#     local_ip = c.getinfo(pycurl.LOCAL_IP)
#     local_port = c.getinfo(pycurl.LOCAL_PORT)
#     speed_download = c.getinfo(pycurl.SPEED_DOWNLOAD)
#     size_download = c.getinfo(pycurl.SIZE_DOWNLOAD)
#     redirect_time = c.getinfo(pycurl.REDIRECT_TIME)
#     redirect_count = c.getinfo(pycurl.REDIRECT_COUNT)
#     redirect_url = c.getinfo(pycurl.REDIRECT_URL)
#     http_code = c.getinfo(pycurl.HTTP_CODE)
#     response_code = c.getinfo(pycurl.RESPONSE_CODE)
#     total_time = c.getinfo(pycurl.TOTAL_TIME)
#     content_type = c.getinfo(pycurl.CONTENT_TYPE)
#     namelookup_time = c.getinfo(pycurl.NAMELOOKUP_TIME)
#     info_filetime = c.getinfo(pycurl.INFO_FILETIME)
#     http_connectcode = c.getinfo(pycurl.HTTP_CONNECTCODE)
#     starttransfer_time = c.getinfo(pycurl.STARTTRANSFER_TIME)
#     pretransfer_time = c.getinfo(pycurl.PRETRANSFER_TIME)
#     header_size = c.getinfo(pycurl.HEADER_SIZE)
#     request_size = c.getinfo(pycurl.REQUEST_SIZE)
#     ssl_verifyresult = c.getinfo(pycurl.SSL_VERIFYRESULT)
#     num_connects = c.getinfo(pycurl.NUM_CONNECTS)
# 
#     return {
#         'effective_url': effective_url,
#         'primary_ip': primary_ip,
#         'primary_port': primary_port,
#         'local_ip': local_ip,
#         'local_port': local_port,
#         'speed_download': speed_download,
#         'size_download': size_download,
#         'redirect_time': redirect_time,
#         'redirect_count': redirect_count,
#         'redirect_url': redirect_url,
#         'http_code': http_code,
#         'response_code': response_code,
#         'total_time': total_time,
#         'content_type': content_type,
#         'namelookup_time': namelookup_time,
#         'info_filetime': info_filetime,
#         'http_connectcode': http_connectcode,
#         'starttransfer_time': starttransfer_time,
#         'pretransfer_time': pretransfer_time,
#         'header_size': header_size,
#         'request_size': request_size,
#         'ssl_verifyresult': ssl_verifyresult,
#         'num_connects': num_connects,
#         # 'proxy_ssl_verifyresult': proxy_ssl_verifyresult,
#         # 'app_connecttime': app_connecttime,
# 
#     }
# 
# Path: falsy/netboy/utils.py
# def setup_curl_for_get(c, p, data_buf, headers=None, share=None):
#     setup_curl_basic(c, p, data_buf, headers, share)
#     httpheader = p.get('httpheader')
#     if httpheader:
#         # c.setopt(pycurl.HEADER, p.get('header', 1))
#         c.setopt(c.HTTPHEADER, httpheader)
#     return c
# 
# def get_title(soup):
#     if soup.title is None:
#         return None
#     text = str(soup.title.get_text())
#     return re.sub('\s+', ' ', text)
# 
# def get_links(soup):
#     return [link['href'] for link in soup.find_all('a', href=True)]
# 
# def get_links2(soup):
#     return [style['href'] for style in soup.find_all('link', href=True)]
# 
# def get_metas(soup):
#     return [meta.get('content') for meta in soup.find_all('meta', content=True)]
# 
# def get_images(soup):
#     return [img['src'] for img in soup.find_all('img', src=True)]
# 
# def get_scripts(soup):
#     return [script['src'] for script in soup.find_all('script', src=True)]
# 
# def get_text(soup):
#     texts = soup.findAll(text=True)
# 
#     def visible(element):
#         if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
#             return False
#         elif re.match('<!--.*-->', str(element)):
#             return False
#         return True
# 
#     visible_texts = filter(visible, texts)
#     return ' '.join(visible_texts)
# 
# def setup_curl_for_post(c, p, data_buf, headers=None, share=None):
#     setup_curl_basic(c, p, data_buf, headers, share)
#     httpheader = p.get('httpheader', ['Accept: application/json', "Content-type: application/json"])
#     if httpheader:
#         # c.setopt(pycurl.HEADER, p.get('header', 1))
#         c.setopt(pycurl.HTTPHEADER, httpheader)
#     post301 = getattr(pycurl, 'POST301', None)
#     if post301 is not None:
#         # Added in libcurl 7.17.1.
#         c.setopt(post301, True)
#     c.setopt(pycurl.POST, 1)
#     postfields = p.get('postfields')
#     if postfields:
#         postfields = json.dumps(postfields, indent=2, ensure_ascii=False)
#         c.setopt(pycurl.POSTFIELDS, postfields)
#     return c


import pycurl
import re
import json
from io import BytesIO
from bs4 import UnicodeDammit, BeautifulSoup
from falsy.netboy.curl_result import curl_result
from falsy.netboy.utils import setup_curl_for_get, get_title, get_links, get_links2, get_metas, get_images, \
    get_scripts, get_text, setup_curl_for_post
# Single curl request:





def post_it(payload):
    if type(payload) is list:
        payload = payload[0]
    c = pycurl.Curl()
    data_buf = BytesIO()
    # header_buf = BytesIO()
    headers = {'count': 0, 'content': [{}]}
    try:

# Path: falsy/netboy/curl_result.py
# def curl_result(c):
#     effective_url = c.getinfo(pycurl.EFFECTIVE_URL)
#     primary_ip = c.getinfo(pycurl.PRIMARY_IP)
#     primary_port = c.getinfo(pycurl.PRIMARY_PORT)
#     local_ip = c.getinfo(pycurl.LOCAL_IP)
#     local_port = c.getinfo(pycurl.LOCAL_PORT)
#     speed_download = c.getinfo(pycurl.SPEED_DOWNLOAD)
#     size_download = c.getinfo(pycurl.SIZE_DOWNLOAD)
#     redirect_time = c.getinfo(pycurl.REDIRECT_TIME)
#     redirect_count = c.getinfo(pycurl.REDIRECT_COUNT)
#     redirect_url = c.getinfo(pycurl.REDIRECT_URL)
#     http_code = c.getinfo(pycurl.HTTP_CODE)
#     response_code = c.getinfo(pycurl.RESPONSE_CODE)
#     total_time = c.getinfo(pycurl.TOTAL_TIME)
#     content_type = c.getinfo(pycurl.CONTENT_TYPE)
#     namelookup_time = c.getinfo(pycurl.NAMELOOKUP_TIME)
#     info_filetime = c.getinfo(pycurl.INFO_FILETIME)
#     http_connectcode = c.getinfo(pycurl.HTTP_CONNECTCODE)
#     starttransfer_time = c.getinfo(pycurl.STARTTRANSFER_TIME)
#     pretransfer_time = c.getinfo(pycurl.PRETRANSFER_TIME)
#     header_size = c.getinfo(pycurl.HEADER_SIZE)
#     request_size = c.getinfo(pycurl.REQUEST_SIZE)
#     ssl_verifyresult = c.getinfo(pycurl.SSL_VERIFYRESULT)
#     num_connects = c.getinfo(pycurl.NUM_CONNECTS)
# 
#     return {
#         'effective_url': effective_url,
#         'primary_ip': primary_ip,
#         'primary_port': primary_port,
#         'local_ip': local_ip,
#         'local_port': local_port,
#         'speed_download': speed_download,
#         'size_download': size_download,
#         'redirect_time': redirect_time,
#         'redirect_count': redirect_count,
#         'redirect_url': redirect_url,
#         'http_code': http_code,
#         'response_code': response_code,
#         'total_time': total_time,
#         'content_type': content_type,
#         'namelookup_time': namelookup_time,
#         'info_filetime': info_filetime,
#         'http_connectcode': http_connectcode,
#         'starttransfer_time': starttransfer_time,
#         'pretransfer_time': pretransfer_time,
#         'header_size': header_size,
#         'request_size': request_size,
#         'ssl_verifyresult': ssl_verifyresult,
#         'num_connects': num_connects,
#         # 'proxy_ssl_verifyresult': proxy_ssl_verifyresult,
#         # 'app_connecttime': app_connecttime,
# 
#     }
# 
# Path: falsy/netboy/utils.py
# def setup_curl_for_get(c, p, data_buf, headers=None, share=None):
#     setup_curl_basic(c, p, data_buf, headers, share)
#     httpheader = p.get('httpheader')
#     if httpheader:
#         # c.setopt(pycurl.HEADER, p.get('header', 1))
#         c.setopt(c.HTTPHEADER, httpheader)
#     return c
# 
# def get_title(soup):
#     if soup.title is None:
#         return None
#     text = str(soup.title.get_text())
#     return re.sub('\s+', ' ', text)
# 
# def get_links(soup):
#     return [link['href'] for link in soup.find_all('a', href=True)]
# 
# def get_links2(soup):
#     return [style['href'] for style in soup.find_all('link', href=True)]
# 
# def get_metas(soup):
#     return [meta.get('content') for meta in soup.find_all('meta', content=True)]
# 
# def get_images(soup):
#     return [img['src'] for img in soup.find_all('img', src=True)]
# 
# def get_scripts(soup):
#     return [script['src'] for script in soup.find_all('script', src=True)]
# 
# def get_text(soup):
#     texts = soup.findAll(text=True)
# 
#     def visible(element):
#         if element.parent.name in ['style', 'script', '[document]', 'head', 'title']:
#             return False
#         elif re.match('<!--.*-->', str(element)):
#             return False
#         return True
# 
#     visible_texts = filter(visible, texts)
#     return ' '.join(visible_texts)
# 
# def setup_curl_for_post(c, p, data_buf, headers=None, share=None):
#     setup_curl_basic(c, p, data_buf, headers, share)
#     httpheader = p.get('httpheader', ['Accept: application/json', "Content-type: application/json"])
#     if httpheader:
#         # c.setopt(pycurl.HEADER, p.get('header', 1))
#         c.setopt(pycurl.HTTPHEADER, httpheader)
#     post301 = getattr(pycurl, 'POST301', None)
#     if post301 is not None:
#         # Added in libcurl 7.17.1.
#         c.setopt(post301, True)
#     c.setopt(pycurl.POST, 1)
#     postfields = p.get('postfields')
#     if postfields:
#         postfields = json.dumps(postfields, indent=2, ensure_ascii=False)
#         c.setopt(pycurl.POSTFIELDS, postfields)
#     return c


# Path: falsy/netboy/one.py
import pycurl
import re
import json
from io import BytesIO
from bs4 import UnicodeDammit, BeautifulSoup
from falsy.netboy.curl_result import curl_result
from falsy.netboy.utils import setup_curl_for_get, get_title, get_links, get_links2, get_metas, get_images, \
    get_scripts, get_text, setup_curl_for_post

# Single curl request:





def post_it(payload):
    if type(payload) is list:
        payload = payload[0]
    c = pycurl.Curl()
    data_buf = BytesIO()
    # header_buf = BytesIO()
    headers = {'count': 0, 'content': [{}]}
    try:

        setup_curl_for_post(c, payload, data_buf, headers)  # header_buf)