-
Posts
7863 -
Joined
-
Last visited
-
Days Won
26
Content Type
Profiles
Forums
Events
Everything posted by Sensei
-
I tried this code on my website, which I knew had relative URLs, and confirmed. item['src'] is relative. In fact, the conversion from relative to absolute URLs can be done using the requests module itself: for item in soup.find_all('img'): src=requests.compat.urljoin(url, item['src']) print(src) ... but there is a possible problem - a web page may have a <base> tag to replace the original URL.... A rarely used thing these days. https://www.w3schools.com/tags/tag_base.asp ( I found a serious mistake in Python requests module - it does not accept URL to local file either in local directory nor with file:// .. it will be harder to debug the code.. )
-
In the above code you showed, the image_url is taken from the user input, but you must use the content returned by BeautifulSoup. https://www.google.com/search?q=scraping+images+python+beautifulsoup Tutorial from the first link: import requests from bs4 import BeautifulSoup def getdata(url): r = requests.get(url) return r.text htmldata = getdata("https://www.geeksforgeeks.org/") soup = BeautifulSoup(htmldata, 'html.parser') for item in soup.find_all('img'): print(item['src']) The src in the above is a relative or absolute URL. You need to convert it to an absolute URL and use it in requests.get() (or alternatives), then output from it in Image.open() to retrieve the image. Then use image object where you need to.
-
Image.open() does not take URL (i.e. Internet location) but path to local file, or file object (stream). https://pillow.readthedocs.io/en/latest/reference/Image.html requests.get() downloads image from URL, and gives Image.open() local path, or stream. https://www.geeksforgeeks.org/how-to-open-an-image-from-the-url-in-pil/
-
Try this: import requests from PIL import Image # python2.x, use this instead # from StringIO import StringIO # for python3.x, from io import StringIO r = requests.get('https://example.com/image.jpg') i = Image.open(StringIO(r.content)) or from PIL import Image import requests img = Image.open(requests.get('http://example.com/image.jpg', stream = True).raw) img.save('image.jpg')
-
What kind of help do you need? How to retrieve HTML from a specific URL? Try this: https://www.tutorialspoint.com/downloading-files-from-web-using-python How to analyze HTML and extract links from it? You need to find the src img tags. string.index(), string.find() or regex can be used to do it. https://www.w3schools.com/python/python_regex.asp 'Dictionary' contains key-value pairs. https://docs.python.org/3/tutorial/datastructures.html#dictionaries You can make abstract datatype in custom class with 'keyword', 'url' and 'path' (on local storage), to have more 'values'.
-
Did you already have Pythagoras' theorem of triangles in math?
-
Is it true that father side has a stronger "heredity"?
Sensei replied to kenny1999's topic in Amateur Science
Scientists use DNA tests.. -
In which is it not?
-
Welcome! To "Westworld".. Don't wake up in a "vat"?
-
Prigozin's second airplane is currently in the middle of the Caspian Sea. At the end of its "trip" to Baku. https://www.planespotters.net/airframe/embraer-erj-135-ra-02748-private/r1m2g6 ps. I'm attaching images because things on the Internet tend to disappear and/or change content all the time..
-
Flight path in the Flight Radar app: https://www.flightradar24.com/data/aircraft/ra-02795#31b7cbfb ps. Note that "calibrated altitude" is incorrect. It should start with an altitude of 0 ft and a ground speed of 0 kts. Some data are cut, missing or altered.
-
https://www.google.com/search?q=steam+turbine+efficiency+formula "Multistage (moderate to high pressure ratio) steam turbines have thermodynamic efficiencies that vary from 65 percent for very small (under 1,000 kW) units to over 90 percent for large industrial and utility sized units. Small, single stage steam turbines can have efficiencies as low as 40 percent."
-
On one (crazy) bookmaking website a month ago I saw bets "how long will Prigozin live. Bet now"..
-
From what I see $172k/year, will receive Long Haul Truck drivers. https://www.cnbc.com/2023/08/18/ups-drivers-can-earn-as-much-as-172000-without-a-degree.html In the U.S., it is a completely different level due to the size of the country. "Long haul drivers earn $172,000 on average ($122,000 plus $50,000 in benefits)" 122k / 12 = 10166 per month / 49 usd/h = 207h per month / 8h per day = 26 days. Here the truck driver has daily limits on how long he can drive the truck and how long he must rest before he can drive again. 207h / 12h per day = 17 days It seems that a truck driver can't have a real family.. Because how? When you are thousands of miles away, in another state.. https://www.google.com/search?q=airline+pilots+salary "How much do A320 pilots make a year?" "The estimated total pay for a A320 Captain is $104,686 per year in the United States area, with an average salary of $83,161 per year. These numbers represent the median, which is the midpoint of the ranges from our proprietary Total Pay Estimate model and based on salaries collected from our users." https://www.glassdoor.com/Salaries/a320-captain-salary-SRCH_KO0,12.htm (and you have to pay $20-30,000 for training out of your own pocket first)
-
..I have not seen Ukrainians with flowers greeting V.V.P. soldiers, either in February 2022 or now..
-
lost typing in the input box.
Sensei replied to studiot's topic in Suggestions, Comments and Support
I lose the content of the edit box if another user wrote a message while I was typing, the forum showed "a new message appeared" and I clicked the button in this pop-up.. Switching to another tab (without scienceforums.net) e.g. Google Translator/Deepl and back is fine. As long as I don't click pop-ups from scienceforums.net, in the middle of edit. I learned to copy and paste long posts "just in case".. ps. @studiot You can always use a keylogger. It will record everything you type anywhere. Then you copy the log from the keylogger and voila. ps2. It does not depend on OS. I am using Linux. It happened on Win7 and Win10 too. ps3. Obviously you used multiple scienceforums.net tabs not back and forward buttons, right? There is only one classical cookie, LocalStorage supercookie and SessionStorage supercookie, with the given name and it is shared by all open tabs. Okay. I clicked F12 in Firefox, then Storage tab, then in Local Storage there is supercookie with name "editorSave.reply-forums/forums-THREAD_NUMBER" and "editorSave.newMessageTo-POST_NUMBER" which are updated in real-time when I type this message. LocalStorage should even survive a computer reset (unless someone has enabled automatic cookie deletion or browser settings). -
The distinction between software and hardware
Sensei replied to geordief's topic in Computer Science
Hardware is created at the factory. It is extremely hard to copy. Copy is never identical (different physical particles are used). Software is a special case of data. Data that is understandable to a processor (compiled into machine code) or understandable to a language interpreter (interpreted text file). It is extremely easy to make an unlimited number of identical copies. Examples of compiled languages are: C, C++, Examples of interpreted languages are: JavaScript, PHP, Perl, Python, Bash, Basic. Examples of mixed compilation-interpretation (i.e. interpretation by a virtual machine): Java, C# Software communicates with hardware through drivers. They are OS-specific, OS-compliant, small programs that read and write hardware registers. Generic drivers are provided by the developer of the operating system (e.g. Microsoft) (they are usually very limited and/or slow). The proper drivers are provided by the hardware manufacturers by their engineers. Low-level software can ignore drivers and have direct access to hardware. This was especially true in the 1980s-90s, on 8 bit computers with primitive operating systems. -
The search engine, after typing a keyword, only searches a previously created database. A crawler is a special server with scripts/programs installed that periodically visits websites and builds a database. How often it visits (downloads) depends on the website. It can range from once a day, to even thousands of times a day. If it is unable to visit the site, this is noted in the database. If it repeats itself frequently (e.g., because you have blocked its IP addresses, or the server is down), it affects the ranking and the ability of new customers to find you by keywords on the Internet. The IP address ranges of Google's crawlers are well known. https://www.google.com/search?q=google+crawler+ip+addresses They are listed on Google's website. https://developers.google.com/search/apis/ipranges/googlebot.json Here's the story of what happened to the guys who blocked Google's robot IP addresses https://support.google.com/webmasters/thread/134144346/block-google-ip-by-mistake-in-server-and-now-getting-indexing-request-rejected-issue?hl=en And general: https://www.google.com/search?q=what+will+happen+if+you+block+google+crawler For legitimate search engines, you can block them in the robots.txt file on the server. This is often done for some special pages that should not be indexed. https://en.wikipedia.org/wiki/Robots.txt (however, 3rd party search engines, hacker's crawlers, can and will ignore it) You can identify the "bad guys" by putting a line in the robots.txt file that disallows some strange path names, and see that they used them. If somebody scanned your server via "nmap", you can identify their IP and block. If somebody tried to connect to ssh 22 port or so, and brute force tried to login to SSH, you can identify their IP and block.
-
Search engine crawlers use thousands of computers with foreign IP addresses.. If you block them, your e.g. Google rank will drop and you won't get new real customers who searched for you through Google, Bing, DuckDuckGo, etc. Hackers don't use VPNs. They intercept civilian, corporate and government computers and then use them to transfer data. For VPNs you have to pay, give your name, surname, address, credit card details etc. The intercepted computer is free.
-
Problem in Taylor and Wheeler's Spacetime Physics
Sensei replied to jlowe22's topic in Homework Help
..or you can write a Python script.. #!/bin/python import sys import math args = len( sys.argv ) if( args != 2 ): print( "The required argument is missing!" ) sys.exit( 1 ) v = float( sys.argv[ 1 ] ) c = 299792458.0 # in vacuum #c = 299705000 # in air fin = 10.525e+9 gamma = ( c + v ) / ( c - v ) fout = fin * gamma df = fout - fin print( "Fs", fin ) print( "v", v ) print() print( "Classic:" ) print( "gamma", gamma ) print( "Fo", fout ) print( "dF", df ) print( "dF (short equation)", 2 * v * fin / c ) gamma_sr = ( math.sqrt( gamma ) - 1 ) * 2 + 1 fout_sr = fin * gamma_sr df_sr = fout_sr - fin print() print( "Special Relativity:" ) print( "gamma", gamma_sr ) print( "Fo", fout_sr ) print( "dF", df_sr ) -
Astronauts use their pee to "flush the toilet", and to drink, and yet they live *) That's true "no waste!".. Maybe it's time to use it in skyscrapers? *) actually, everyone in this world uses e.g. dinosaur piss water..
-
After using salt water, sediment will build up in the toilet and pipes. https://www.google.com/search?q=saltwater+sediments+in+pipes
-
Problem in Taylor and Wheeler's Spacetime Physics
Sensei replied to jlowe22's topic in Homework Help
@studiot Shouldn't the relativistic Doppler effect formula be used instead of the classical one formula for sound waves? (i.e. sqrt() is needed) -
This is what the Crimea bridge looked like from the train on July 30: