Esempio n. 1
0
def get_images(client, data):

    print('[GET] getting images...')

    images = []
    reply = b''
    for imgtag in data.find_all('img'):
        src = imgtag.get('src')

        src = src.replace(" ", "_")
        src = src.replace("%20", "_")
        request = get_from_src(src, client.addr, client)

        client.sock.send(request)
        headers = head.get_head(client)
        reply = get.get_data(headers, client)

        src = src.split("/")[-1]

        if (src.startswith("/") == False):
            src = "/{}".format(str(src))
        url = "{}{}".format(str(client.addr), str(src))

        imgtag['src'] = "./images{}".format(src)

        print('Request: ', str(request))

        images.append((src, reply))

    return images
Esempio n. 2
0
def main(country, yeari, yearf):
    data = get_data()
    cldata = clean.clean_data(data)
    filfix = filter_fixer(cldata, country, yeari, yearf)
    pop_plot_r, gr_plot_r = analyse_this(filfix)
    nomb, altnomb, capi, regi, langu, cpopul = enrich_that(filfix)
    rpdf = make_PDF(nomb, altnomb, capi, regi, langu, cpopul, pop_plot_r,
                    gr_plot_r)
    return rpdf
Esempio n. 3
0
def task(q, bloom, batch_size):
    pid = os.getpid()
    print(f"开启任务线程-{pid}:")
    urls = [q.get() for i in range(batch_size) if not q.empty()]
    urls = [url for url in urls if urlparse(url).netloc not in bloom]
    print(urls)
    r = get_data(urls)
    # update visited site
    list(map(bloom.add, [urlparse(url).netloc for url in urls]))
    all_friend_links = list(chain(*[site.friends for site in r]))

    return pid, all_friend_links
Esempio n. 4
0
    def send_msg(self):
        data = ''
        # === Handling GET ===
        """
            Go to file: [[get.py]].
        """
        if self.command == "GET":
            get.setup(self)
            headers = head.get_head(self)
            data, content_type = get.get_data(headers, self)
            if content_type == "html":
                parser_.set_html_file(self, data)
            else:
                parser_.set_object(self, data)
        # === Handling PUT ===
        """
            Go to file: [[put.py]].
        """
        if self.command == "PUT":
            put.put_data(self)
            headers = head.get_head(self)
        # === Handling POST ===
        """
            Go to file: [[post.py]].
        """
        if self.command == "POST":
            post.post_data(self)
            headers = head.get_head(self)
        # === Handling HEAD ===
        """
            Go to file: [[head.py]].
        """
        if self.command == "HEAD":
            head.head_data(self)

        return data
Esempio n. 5
0
Created on Thu Aug 13 15:26:08 2020

@author: COM
"""

#%%

# import sys
# sys.path.append("C:\\pylib")
import cx_Oracle
import os
import get
import recommend_hybrid
import recommend_svd

review = get.get_data()


def recommend(user_i, df):
    try:
        result = recommend_hybrid.do(user_i, df)
        if len(result) < 100:
            result2 = recommend_svd.do(user_i, df)
            for place in result2["place"]:
                if place not in result["place"]:
                    row = {
                        "place":
                        place,
                        "rating":
                        float(result2.loc[result2["place"] == place, "rating"])
                    }