SHARE
TWEET

Untitled

a guest Jun 25th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ----------------------
  2. def get_ad_data(ad, ads_len, signal, status_bar_signal):
  3.     try:
  4.     full_descr = get_full_descr(url, ads_len, signal, status_bar_signal)
  5.     except:
  6.     full_descr = ''
  7.     try:
  8.     name_adv = get_name_adv(url, ads_len, signal, status_bar_signal)
  9.     except:
  10.     name_adv = 'namenone'
  11.  
  12.     data = {'advname': name_adv,
  13.             'description': full_descr,
  14.             }
  15.  
  16. write_csv(data)
  17.  
  18. -----------------------
  19. def get_name_adv(url, ads_len, signal, status_bar_signal):
  20. global percents
  21. try:
  22.     html = get_html(url)
  23.     soup = BeautifulSoup(html, 'lxml')
  24.     good_page_test = soup.find('div', class_='item-view-header').find_all('h1')
  25. except:
  26.     html = get_html_proxy(url, signal)
  27.     soup = BeautifulSoup(html, 'lxml')
  28.     name_adv_a = soup.find('div', class_='seller-info-name').find_all('a')
  29. else:
  30.     name_adv_a = soup.find('div', class_='seller-info-name').find_all('a')
  31. finally:
  32.     name_adv = ""
  33.     for a in name_adv_a:
  34.         name_adv += a.text
  35.  
  36. percents = percents + (100 / ads_len)
  37. status_bar_signal.emit(int(percents))
  38. return name_adv
  39. -------------------------------
  40. def get_full_descr(url, ads_len, signal, status_bar_signal):
  41. global percents
  42. try:
  43.     html = get_html(url)
  44.     soup = BeautifulSoup(html, 'lxml')
  45.     good_page_test = soup.find('div', class_='item-view-header').find_all('h1')
  46. except:
  47.     html = get_html_proxy(url, signal)
  48.     soup = BeautifulSoup(html, 'lxml')
  49.     full_descr_p = soup.find('div', class_='item-description-text').find_all('p')
  50. else:
  51.     full_descr_p = soup.find('div', class_='item-description-text').find_all('p')
  52. finally:
  53.     full_descr = ""
  54.     for p in full_descr_p:
  55.         full_descr += p.text
  56.  
  57. percents = percents + (100 / ads_len)
  58. status_bar_signal.emit(int(percents))
  59. return full_descr
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top