Scraping (BeautifulSoup) no tag

I am very new to scraping, so as I understand, BeautifulSoup only extracts the data found inside tags (with functions like get, find, find_all ...) The source code of the website i am scraping is displaying the various items inside the same tag and t

Django relies on frame authentication

I would like create authentication in Django. I'm trying to do everything according to this. Unfortunately, at this moment I have two problems. Firstly, when I try to add from rest_framework.authtoken import views I have conflict with from companies

Recursive implementation of the binary python search tree

I'm trying to implement Binary Search tree in python using recursion. I got trapped in some infinite recursions happening in my program.I'm making recursive calls to the function RecursBST by passing address and the data until the top traverse down t

Unexpected results with try, with open

This question already has an answer here: Recursive function returning none in Python [duplicate] 2 answers python recursion return None type 2 answers Return in Recursive Function 3 answers Python recursion and return statements 2 answers Can't figu

Input constantly received as 'str'

base = (.75) hood = (.70) pipeAura = (.9) cloak = (.85) glimmer = (.85) null = (.78) heap = (.88) corrosive = (.75) spiritBear = (.67) spellShield = (.5) berserkersBlood = (.5) pipe = hood * pipeAura antimage = spellShield * base viper = corrosive *

How to randomly select some lines of pandas data?

I have a pandas dataframe df which contains a column amount. For many rows, the amount is zero. I want to randomly remove 50% of the rows where the amount is zero, keeping all rows where amount is nonzero. How can I do this?pandas Using query + sampl

I'm trying to use classes with a dictionary with python

class student(object): def __init__(self, name, age, year): self.name, self.age, self.year = name, age, year self.grades=[] self.grade={} print(name,'-------->','Age:',age,'','Year:',year) def set_grades(self,score): self.grades.append(score) def get

Returns the list of items that exceed all previous items

I am new to Python, can anyone please point out the mistake, i have made in the code: numlist = [3,2,5,5,7,6,1,8,4] def peaks(numlist): exceed = [] for elem in numlist: for num in exceed: if elem not in exceed: if num in exceed < elem in numlist: exc

Is it possible to prioritize a lock?

I have a multiprocessing program where one process adds elements to a shared list (multiprocessing.Manager().list()) several other processes consume these elements from that list (and remove them); they run until there is something to process in the

to remove duplicate strings in a python list

This question already has an answer here: How do you remove duplicates from a list in whilst preserving order? 33 answers I have a problem in my code where I have the following: import random Probabilities={'AA':0.2,"TT":0.2, "GG":0.1,

split the text list into nGrams into Python

I have to split a text file into a specific amount of words per list in list, probably be best to show in example. say the text file looks like this "i am having a good day today" i have to write a function which looks like this ngrams.makeNGram

How to take an iteration output, store this in a dictionary

So I have this script (running Python 3.5) using Google API and Newspaper. It searches google for articles that have to do with sleep. And then using Newspaper, I iterate over those URLS. And all I'm asking Newspaper to do is return a list of keyword

Python CSV delete empty lines

This question already has an answer here: CSV file written with Python has blank lines between each row 5 answers Im having a hard time trying to delete empty(blank) rows from a csv file using python 3.4.3. Each time I run my script the output remain

Popen.communicate () launches UnicodeDecodeError

I have this code: def __executeCommand(self, command: str, input: str = None) -> str: p = sub.Popen(command, stdout=sub.PIPE, stderr=sub.PIPE, stdin=sub.PIPE, universal_newlines=True) p.stdin.write(input) output, error = p.communicate() if (len(error

Recursively generate combinations with Python

I am trying to provide a recursive method that provides a list of all the possible combinations when given a list of courses. E.g course = [Entree, Dessert] This is what I have so far: Entree = ["pumkinsoup","antipasto"] Dessert = [&qu

Create a file in the Python subdirectory?

In my Python script, I need to create a new file in a sub directory without changing directories, and I need to continually edit that file from the current directory. My code: os.mkdir(datetime+"-dst") for ip in open("list.txt"): with

Problem with the evaluation of an input sentence in python

I am in a class teaching python and am a beginner at any sort of coding. I keep running into this problem and I can't find anything in my text book or additional handouts explaining what I'm doing wrong. Here is an example taken from one of the exerc

Make a string with a string and an integer in Python

I get this error when trying to take an integer and prepend "b" to it, converting it into a string: File "program.py", line 19, in getname name = "b" + num TypeError: Can't convert 'int' object to str implicitly That's relate