Found 34469 Articles for Programming

Web Scraping using Python and Scrapy?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

552 Views

One of the best frameworks for developing crawlers is scrapy. Scrapy is a popular web scraping and crawling framework utilizing high-level functionality to make scraping websites easier.Installation Installing scrapy in windows is easy: we can use either pip or conda(if you have anaconda). Scrapy runs on both python 2 and 3 versions.pip install ScrapyOrconda install –c conda-forge scrapyIf Scrapy is installed correctly, a scrapy command will now be available in the terminal −C:\Users\rajesh>scrapy Scrapy 1.6.0 - no active project Usage: scrapy [options] [args] Available commands: bench    Run quick benchmark test fetch    Fetch a URL using the ... Read More

Instant hashCode() method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

131 Views

The hash code for a particular Instant object can be obtained using the hashCode() method in the Instant class in Java. This method requires no parameters and it returns the hash code for the Instant object.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; import java.time.temporal.ChronoUnit; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       System.out.println("The current instant is: " + i);       int hashCode = i.hashCode();       System.out.println("The Hash Code value for the instant is: " + hashCode);    } }OutputThe ... Read More

The addIfAbsent() method of CopyOnWriteArrayList in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

506 Views

The addIfAbsent() method appends the element if it is not in the list. If the element is already in the list, then FALSE is returned.The syntax is as follows.public boolean addIfAbsent(E ele)Here, ele is the element to be added to this list, if it is not already in the list.To work with CopyOnWriteArrayList class, you need to import the following package.import java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class addIfAbsent() method in Java.Example Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] args) {       CopyOnWriteArrayList arrList = new CopyOnWriteArrayList();       arrList.add(30); arrList.add(40); ... Read More

LongStream peek() method in Java

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

115 Views

The peek() method of the LongStream class returns a stream with the elements of this stream, additionally performing the provided action on each element as elements are consumed from the resulting stream.The syntax is as follows −LongStream peek(LongConsumer action)Here, LongConsumer represents an operation that accepts a single long-valued argument and returns no result. The action parameter is a non-interfering action to perform on the elements as they are consumed from the stream.To use the LongStream class in Java, import the following package −import java.util.stream.LongStream;The following is an example to implement LongStream peek() method in JavaExample Live Demoimport java.util.stream.LongStream; public class Demo ... Read More

LongStream rangeClosed() method in Java

Anvi Jain
Updated on 30-Jul-2019 22:30:25

234 Views

The rangeClosed() method of the LongStream class in Java returns a sequential ordered LongStream from startInclusive to endExclusive by an incremental step of 1. This is inclusive of the initial element and the last element.The syntax is as follows −static LongStream rangeClosed(long startInclusive, long endExclusive)Here, startInclusive is the first value, whereas the endExclusive is the last.To use the LongStream class in Java, import the following package −import java.util.stream.LongStream;The following is an example to implement LongStream rangeClosed() method in Java −Example Live Demoimport java.util.stream.LongStream; public class Demo { public static void main(String[] args) { ... Read More

Collectors averagingDouble() method in Java 8

Smita Kapse
Updated on 30-Jul-2019 22:30:25

386 Views

The averagingDouble() method of the Collectors class in Java 8 returns a Collector that is the arithmetic mean of a double-valued function applied to the input elements.The syntax is as follows −public static Collector averagingDouble(ToDoubleFunction

Data visualization with different Charts in Python?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

234 Views

Python provides various easy to use libraries for data visualization. Good thing is that these libraries works with small or large datasets.Some of the most commonly used python libraries for data visualizations are −MatplotlibPandasPlotlySeabornBelow we are going to plot different types of visualization chart for one fixed data to better analyse that data.We are going to analyze below data set to visualize through different charts −Country or AreaYear(s)VariantValueIndia2019Medium1368737.513India2019High1378419.072India2019Low1359043.965India2019Constant fertility1373707.838India2019Instant replacement1366687.871India2019Zero migration1370868.782India2019Constant mortality1366282.778India2019No change1371221.64India2019Momentum1367400.614Basic Plot Let's create some basic plots: Line plots, scatter plots and histogramsLine PlotsLine graphs are plots where a line is drawn to indicate a relationship between a particular ... Read More

The set() method of CopyOnWriteArrayList in Java

George John
Updated on 30-Jul-2019 22:30:25

76 Views

The set() method of the CopyOnWriteArrayList class is used to replace the element at the specified position in this list with the specified element. It returns the element that gets replaced.The syntax is as followspublic E set(int index, E ele)Here, the parameter index is the index of the element to replace and ele is the element to be stored at the specified position.To work with CopyOnWriteArrayList class, you need to import the following packageimport java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class set() method in JavaExample Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo { public static void main(String[] ... Read More

ArrayBlockingQueue clear() Method in Java

Chandu yadav
Updated on 30-Jul-2019 22:30:25

81 Views

The clear() method of the ArrayBlockingQueue class in Java is used to remove all the elements from this queue.The syntax is as followspublic void clear()To work with ArrayBlockingQueue class, you need to import the following packageimport java.util.concurrent.ArrayBlockingQueue;The following is an example to implement clear() method of Java ArrayBlockingQueue classExample Live Demoimport java.util.ArrayList; import java.util.Iterator; import java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) throws InterruptedException { ArrayBlockingQueue q = new ArrayBlockingQueue(10); q.add(120); q.add(10); ... Read More

Generate Infinite Stream of Integers in Java using Random.ints()

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

166 Views

To generate Infinite Stream of Integers, you can use the Random class and its ints() methodRandom.ints()Here, we have used the ints() method to get the next integer.The following is an example displaying how to generate Infinite Stream of Integers with Random.ints() in JavaExampleimport java.util.stream.*; import java.util.*; public class Demo { public static void main(String[] args) { Random r = new Random(); r.ints().forEach(System.out::println); } }Output78799000099 8787879898 2872737888 . . .

Advertisements