Ejemplo n.º 1
0
def create_review(trail_id):
    # change to <trail>.query....etc
    trail = Trail.query.filter_by(id=trail_id).first()
    if trail is None:
        return failure_response('Trail not found!')
    body = json.loads(request.data)
    # image_data = body.get("image_data")
    # if image_data is not None:
    #     asset = Asset(image_data=image_data)
    # else:
    #     asset = Asset(image_data="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAYAAAB5fY51AAANhklEQVR4nO3daW8bVRuA4ScLpDQtktWmNEAKCASRqkp84v//AVAdh7Qhi50QL+Nt4mW8ZmbeD1V4p26SepkzZx77vj5C8Dkq6p1zjmdZC8MwFABQYN32BABgWgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGgQLgBoEC4AaBAuAGpu2JyAi0mw2JZ/P254GgAe8evVKdnZ2rM4hFcEaj8fS6XRsTwPAA8bjse0psCUEoAfBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgRioekRy39fV1efnype1pAFY5jiO+79ueRqyWNli//vqr7WkAVjWbzaULFltCAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqECwAahAsAGoQLABqbNqeAD4YDAYyHo9lY2NDHj9+bHs6QCoRLAvCMBTXdaXRaEi9XpfhcPjJz2xubkomk5EXL15IJpORzU3+VwH8LUhYuVyWQqFwZ6Sibm5upFarSa1Wk42NDdnb25O9vT3Z2NhIaKZA+hCshHieJ0dHR+J53sz/re/7UigUpFQqyW+//SbPnj0zMEMg/Th0T0Cj0ZC//vprrlhFjUYjyeVycnl5GdPMAF0IlmG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KgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoAbBAqAGwQKgBsECoMZaGIah7UkAwDRYYQFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVCDYAFQg2ABUINgAVDjfwXxayX33T/OAAAAAElFTkSuQmCC")
    # db.session.add(asset)
    # image_id = asset.id

    new_review = Review(title=body.get('title'),
                        body=body.get('body'),
                        rating=body.get('rating'),
                        username=body.get('username'),
                        trail_id=trail_id,
                        trail=trail
                        # image_id = image_id,
                        # image=asset
                        )
    if new_review.title is None or new_review.rating is None:
        return failure_response('Could not create Review for trail')
    if new_review.body is None or new_review.username is None:
        return failure_response('Could not create Review for trail')
    db.session.add(new_review)
    trail.reviews.append(new_review)
    db.session.commit()
    # update_rating(trail)
    return success_response(new_review.serialize())
Ejemplo n.º 2
0
def create_review(reviewer_name, title, description, rating, event_id):
    new_review = Review(reviewer_name=reviewer_name,
                        title=title,
                        description=description,
                        rating=rating,
                        event_id=event_id)
    db.session.add(new_review)
    db.session.commit()
    return new_review.serialize()
Ejemplo n.º 3
0
def create_review(review_text, review_book_id, username, password):
  book = Book.query.filter_by(id=review_book_id).first()
  u = get_user(username, password)
  if book is None or u is None:
    return None
  new_review = Review(content = review_text, book_id = review_book_id, user_id = u.get_id())
  db.session.add(new_review)
  db.session.commit()
  return new_review.serialize_review()
Ejemplo n.º 4
0
def create_review(username, review, recommend, book_id):
    # if recommend == True:
    #     recommendation = "Yes"
    # else:
    #     recommendation = "No"

    new_review = Review(username=username,
                        review=review,
                        recommend=recommend,
                        book=book_id)

    db.session.add(new_review)
    db.session.commit()
    return new_review.serialize()
Ejemplo n.º 5
0
def comment():
    if request.method == 'POST':
        email = global_email
        if email != None:
            comment = request.form ['comment']

            current_date = datetime.datetime.now()
            date = current_date.strftime("%d"), current_date.strftime("%b"), current_date.strftime("%Y")
            date = ' '.join(date)

            all = db.session.query(Review).all()
            i = 0
            for a in all:
                i = i+1

            row = Review(comment_id=i, name=global_name, email=email, comment=comment, date=date)
            db.session.add(row)
            query = db.session.query(Review).all()
            db.session.commit()
            return render_template('coment.html', comments=query, email=global_email, name=global_name)

        else:
            query = db.session.query(Review).all()
            return render_template('coment.html', comments=query)

    else:
        query = db.session.query(Review).all()
        email =global_email
        if email != None:
            search = db.session.query(Users).filter_by(email=email).all()
        return render_template('coment.html', comments=query, email=email,name=global_name)
Ejemplo n.º 6
0
    def extract_concert_reviews_for_performer(self, performer):
        existing = db.get_review_by_teamband_name(self.session, performer)
        if existing.count() >= 2:
            print performer + " was already in the database"
            return

        print "now scraping " + performer

        urls = self.googler.google_concert_reviews_urls(performer +
                                                        " concert reviews")

        for url in urls[:2]:
            if db.get_review_by_url(self.session, url).count() != 0:
                continue
            response = requests.get(url)
            tree = BeautifulSoup(response.text)
            most_likey_review = self.extractor.extract(tree)

            r = Review(teamband_name=performer,
                       url=url,
                       review=most_likey_review)
            self.session.add(r)
            self.session.commit()

            time.sleep(10)
Ejemplo n.º 7
0
def create_review_for_restaurant(restaurant_id, body):
    user_id = body.get("user_id")
    user = User.query.filter_by(id=user_id).first()
    restaurant = Restaurant.query.filter_by(id=restaurant_id).first()
    if user is None or restaurant is None:
        return None
    review = Review(rating=body.get("rating"),
                    content=body.get("content"),
                    user_id=user_id,
                    restaurant_id=restaurant_id)
    update_rating_for_restaurant(restaurant_id, body.get("rating"),
                                 len(restaurant.reviews))
    db.session.add(review)
    db.session.commit()

    return review.serialize()
Ejemplo n.º 8
0
def persist_review_data(session, app_row_id, review_data):
    for review in review_data:
        r = Review(app_id=app_row_id,
                   content=review['content'],
                   review_native_id=review['reviewId'],
                   score=review['score'],
                   reply_content=review['replyContent'],
                   created_at=review['at'])
        session.add(r)
        session.commit()
Ejemplo n.º 9
0
def comment():
    if 'email' in session:
        email = session['email']
        name = session['name']
    else:
        email = None
        name = None
    if request.method == 'POST':
        if email != None:
            comment = request.form['comment']

            current_date = datetime.datetime.now()
            date = current_date.strftime("%d"), current_date.strftime(
                "%b"), current_date.strftime("%Y")
            date = ' '.join(date)

            all = session_app.query(Review).all()
            i = 1
            for a in all:
                i = i + 1

            row = Review(comment_id=i,
                         name=name,
                         email=email,
                         comment=comment,
                         date=date)
            session_app.add(row)
            query = session_app.query(Review).all()
            session_app.commit()
            return render_template('coment.html',
                                   comments=query,
                                   email=email,
                                   name=name)

        else:
            query = session_app.query(Review).all()
            return render_template('coment.html',
                                   comments=query,
                                   email=email,
                                   name=name,
                                   action=1)

    else:
        query = session_app.query(Review).all()

        return render_template('coment.html',
                               comments=query,
                               email=email,
                               name=name)
Ejemplo n.º 10
0
def multi_thread_user_communication(user_id):
    print user_id
    try:
        personal_update = threads[user_id].get()

        # Получаем информацию о сообщении
        offset, user_id, chat_id, username, text, message_date, photo = extract_update_info(
            personal_update)
        print personal_update

        if photo is not None:
            if user_id in review_stages and review_stages[user_id] == "picture":
                unfilled_reviews[user_id].image_id = photo.file_id
                write_review(user_id)
                answer(log_file,
                       bot,
                       user_id,
                       chat_id,
                       "Спасибо за отзыв!\n",
                       reply_markup,
                       del_msg=False)
            else:
                result = bot.send_message(chat_id, PHOTO_IS_IN_PROCESS).wait()
                print result
                da = get_info_by_url(bot, chat_id, user_id,
                                     get_photo_url(photo))
                try:
                    product_id = int(da[0].split()[2])
                except:
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           PHOTO_IS_NONE,
                           reply_markup,
                           del_msg=False)
                    return
                if da[0] is not None:
                    last_product[user_id] = product_id

                k = 0
                for i in da:
                    if k == 0:
                        print i
                        if i is not None:
                            answer(log_file,
                                   bot,
                                   user_id,
                                   chat_id,
                                   ' '.join(i.split()[4:]),
                                   reply_markup,
                                   del_msg=False)
                        else:
                            answer(log_file,
                                   bot,
                                   user_id,
                                   chat_id,
                                   "Мы не знаем что это :(",
                                   reply_markup,
                                   del_msg=False)
                            return
                    elif k == 1:
                        print i
                        if i is not None:
                            answer(log_file,
                                   bot,
                                   user_id,
                                   chat_id,
                                   "Средняя оценка: " + u"🍔" * int(i),
                                   reply_markup,
                                   del_msg=False)
                    k += 1

                reviews = db.get_reviews(product_id)
                if list(reviews) != []:
                    for r in reviews:
                        if r.image_id is not None:
                            bot.send_photo(chat_id=chat_id, photo='https://api.telegram.org/bot' + BOT_TOKEN + \
                                '/getFile?file_id=' + str(r.image_id))
                            break

                    for r in reviews:
                        answer(log_file,
                               bot,
                               user_id,
                               chat_id,
                               "%s: %s\n\t%s" %
                               (r.user_id, u"🍔" * r.rating, r.text),
                               reply_markup,
                               del_msg=False)
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           "Оставить свой: /review\n",
                           reply_markup,
                           del_msg=False)
                else:
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           "Оставить первый отзыв: /review\n",
                           reply_markup,
                           del_msg=False)

        else:
            if text == "/review":
                unfilled_reviews[user_id] = Review(user_id,
                                                   last_product[user_id], None,
                                                   None, None, None)
                answer(
                    log_file,
                    bot,
                    user_id,
                    chat_id,
                    "Ваша оценка:\n/star1\n/star2\n/star3\n/star4\n/star5\n",
                    reply_markup,
                    del_msg=False)
                review_stages[user_id] = "rating"
            elif user_id in review_stages:
                if review_stages[user_id] == "rating":
                    #exception possible
                    unfilled_reviews[user_id].rating = int(text[-1])
                    #answer(log_file, bot, user_id, chat_id, "Цена товара:\n", reply_markup, del_msg=False)
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           "Отзыв:\n",
                           reply_markup,
                           del_msg=False)
                    review_stages[user_id] = "text"
                elif review_stages[user_id] == "price":
                    #exception possible
                    unfilled_reviews[user_id].price = float(text)
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           "Отзыв:\n",
                           reply_markup,
                           del_msg=False)
                    review_stages[user_id] = "text"
                elif review_stages[user_id] == "text":
                    unfilled_reviews[user_id].text = text
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           "Фотография: (пропустить - /skip)\n",
                           reply_markup,
                           del_msg=False)
                    review_stages[user_id] = "picture"
                elif review_stages[user_id] == "picture" and text == "/skip":
                    write_review(user_id)
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           "Спасибо за отзыв!\n",
                           reply_markup,
                           del_msg=False)

            else:
                if user_id in review_stages:
                    write_review(user_id)
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           "Спасибо за отзыв!\n",
                           reply_markup,
                           del_msg=False)
                else:
                    answer(log_file,
                           bot,
                           user_id,
                           chat_id,
                           PHOTO_IS_NONE,
                           reply_markup,
                           del_msg=False)
            return
    except ContinueError as exc_txt:
        answer(log_file,
               bot,
               user_id,
               chat_id,
               exc_txt.txt,
               reply_markup,
               del_msg=False)
    except EasyError as exc_txt:
        log_write(log_file, 'sys', exc_txt.txt)
Ejemplo n.º 11
0
                './/h3[@class="bv-author"]').text

            # We use date_ to avoid naming conflict with the date method from datetime.
            date_ = review.find_element_by_xpath(
                './/meta[@itemprop="datePublished"]').get_attribute('content')
            year, month, day = map(lambda x: int(x), date_.split('-'))
            date_ = date(year, month, day)

            rating = review.find_element_by_xpath(
                './/span[@class="bv-rating-stars-container"]/span').text
            rating = int(re.search('\d+', rating).group())

            # create a Review object that correponds to one row of our table.
            review = Review(username=username,
                            title=title,
                            content=content,
                            date=date_,
                            rating=rating)
            review.save()

        # Locate the next button on the page.
        wait_button = WebDriverWait(driver, 10)
        current_button = wait_button.until(
            EC.element_to_be_clickable((
                By.XPATH,
                '//li[@class="bv-content-pagination-buttons-item bv-content-pagination-buttons-item-next"]'
            )))
        prev_button = current_button
        current_button.click()
    except Exception as e:
        print(e)
Ejemplo n.º 12
0
			# To get the attribute instead of the text of each element, use 'element.get_attribute()'
			try:
				title = review.find_element_by_xpath('.//div[@class="NHaasDS75Bd fontSize_12 wrapText"]').text
			except:
				continue

			text = review.find_element_by_xpath('.//span[@class="pad6 onlyRightPad"]').text
			username = review.find_element_by_xpath('.//span[@class="padLeft6 NHaasDS55Rg fontSize_12 pad3 noBottomPad padTop2"]').text
			date_published = review.find_element_by_xpath('.//span[@class="NHaasDS55Rg fontSize_12  pad3 noBottomPad padTop2"]').text
			rating = review.find_element_by_xpath('.//span[@class="positionAbsolute top0 left0 overflowHidden color_000"]').get_attribute('style')
			rating = int(re.findall('\d+', rating)[0])/20		
	

			# create a Review object that correponds to one row of our table.
			cur_review = Review(username=username,
							title=title,
							text=text,
							date_published=date_published,
							rating=rating)
			cur_review.save()

		# Locate the next button on the page.
		wait_button = WebDriverWait(driver, 10)
		next_button = wait_button.until(EC.element_to_be_clickable((By.XPATH,
									'//li[@class="nextClick displayInlineBlock padLeft5 "]')))
		next_button.click()
	except Exception as e:
		print(e)
		csv_file.close()
		driver.close()
		break
Ejemplo n.º 13
0
                    recommending =''
                helpful = review.find_element_by_xpath(
                    './/button[@class="border_grayThree NHaasDS55Rg fontSize_12 height48 width100p positiveReviewFeedBack"]/span').text
                helpful = int(re.findall('\d+', helpful)[0])
                unhelpful = review.find_element_by_xpath(
                    './/button[@class="border_grayThree NHaasDS55Rg fontSize_12 height48 width100p negativeReviewFeedBack"]/span').text
                unhelpful = int(re.findall('\d+', unhelpful)[0])
                # if saving data to mysql triggers exception error, skip this data row
                #print('helpful, unhelpful', helpful, unhelpful)
                try:
                    current = Review(
                        store          = 'verizon',
                        skuId          = skuId,
                        username       = username,
                        text           = text,
                        title          = title,
                        date_published = date_published,
                        rating         = rating,
                        recommending   = recommending,
                        helpful        = helpful,
                        unhelpful      = unhelpful
                        )
                    current.save()
                    
                except:
                    continue

            # end of for loop
            

            
            # Locate the next button element on the page and then call `button.click()` to click it.
Ejemplo n.º 14
0
import re
from time import sleep
import pandas as pd
from datetime import datetime
"""
class Reviews(Model):
    title_id = TextField()
    review_id = CharField(20, unique=True)
    summary = TextField(null=True)
    content = TextField(null=True)
    username = TextField(null=True)
    date = DateTimeField(null=True)
    rating = TextField(null=True)
    scale = IntegerField(null=True)
    helpful_votes = IntegerField(null=True)
    total_votes = IntegerField(null=True)
            
"""

query = Review.select()
year = []

res = (Reviews
       .insert_from(
           Review.select(Review.title_id, Review.review_id, Review.summary, Review.content, Review.username, Review.date, \
                         None, Review.scale, Review.helpful_votes, Review.total_votes).where(Review.rating == ''),
           fields=[Reviews.title_id, Reviews.review_id, Reviews.summary, Reviews.content, Reviews.username, Reviews.date, \
                   Reviews.rating, Reviews.scale, Reviews.helpful_votes, Reviews.total_votes])

       .execute())