小编Oli*_*POP的帖子

使用Curl/PHP提取HTML数据

我在PHP中有以下代码

$ch = curl_init("http://blog.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);      
curl_close($ch);
echo $output;
Run Code Online (Sandbox Code Playgroud)

我试图导入的代码块之间<div id="content"></div>我想知道这个提取码的最好方式.

php string wordpress curl cross-domain

2
推荐指数
1
解决办法
7134
查看次数

WordPress中的自定义表单并将值存储到自定义数据库中

我的WordPress网站中有2个文本字段的简单表单。我创建了一个新的页面模板,并添加了以下HTML代码:

这是HTML:

<form action="<?php the_permalink(); ?>" id="customform" method="post">
Field 1: <input type="text" name="field1" id="field1">
Field 2: <input type="text" name="field2" id="field2">
<input type="submit" name="submit" id="submit">
</form>
Run Code Online (Sandbox Code Playgroud)

现在我要做的就是,无论用户输入什么内容,它都将其存储到mySQL例如,与WordPress在同一数据库中)表中test_form

我该如何实现?

mysql forms wordpress

2
推荐指数
1
解决办法
2542
查看次数

maven不能在java 1.6中编译

如何强制maven编译1.6兼容源

我在eclipse中用maven制作了web-app项目.将web.xml更改为使用3.0版本 - >然后更新配置,现在我无法启动tomcat.我发现我必须强制maven编译源1.6兼容,我必须添加

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
 <configuration>
    <source>1.7</source>
    <target>1.7</target>
    <showDeprecation>true</showDeprecation>
    <showWarnings>true</showWarnings>
    <executable>${env.JAVA_HOME_7}/bin/javac</executable>
    <fork>true</fork>
</configuration>
Run Code Online (Sandbox Code Playgroud)

但日食中的有效pom是不可编辑的

所以有没有maven兼容eclipse或任何其他方式强制maven编译源1.6版本?

eclipse maven

1
推荐指数
1
解决办法
7366
查看次数

从集合中查找重复项的最快方法是什么

这是我尝试过的,不知怎的,我觉得这不对,或者这不是性能最好的应用程序,所以有更好的方法来从Map中搜索和获取重复值,或者事实上任何集合.并且可以更好地遍历集合.

public class SearchDuplicates{
    public static void main(String[] args) {
        Map<Integer, String> directory=new HashMap<Integer, String>();
        Map<Integer, String> repeatedEntries=new HashMap<Integer, String>();

        // adding data
        directory.put(1,"john");
        directory.put(2,"michael");
        directory.put(3,"mike");
        directory.put(4,"anna");
        directory.put(5,"julie");
        directory.put(6,"simon");
        directory.put(7,"tim");
        directory.put(8,"ashley");
        directory.put(9,"john");
        directory.put(10,"michael");
        directory.put(11,"mike");
        directory.put(12,"anna");
        directory.put(13,"julie");
        directory.put(14,"simon");
        directory.put(15,"tim");
        directory.put(16,"ashley");

        for(int i=1;i<=directory.size();i++) {
           String result=directory.get(i);
           for(int j=1;j<=directory.size();j++) {
              if(j!=i && result==directory.get(j) &&j<i) {
                 repeatedEntries.put(j, result);
              }
           }
           System.out.println(result);
        }
        for(Entry<Integer, String> entry : repeatedEntries.entrySet()) {
           System.out.println("repeated "+entry.getValue());   
        }
   }
}
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.提前致谢

java collections

1
推荐指数
1
解决办法
2166
查看次数

Java Set,包含,false结果

EventObject target = new EventObject("e2");
Set<EventObject> Following = o.getFollowingEvents(e1);
System.out.println("Elements : "+Following.toString());
System.out.println(e2.toString());
System.out.println(Following.toString()+" contains "+e2+" ? = "+Following.contains(target));
Run Code Online (Sandbox Code Playgroud)

打印:

Elements : [e2, e5, end, T]
e2
[e2, e5, end, T] contains e2 ? = false
Run Code Online (Sandbox Code Playgroud)

等于和比较:

@Override
public int compareTo(EventObject o) {
    return this.getName().compareTo(o.getName());
}

@Override 
public boolean equals(Object obj) {
    return (obj instanceof EventObject) && (this.compareTo((EventObject) obj) == 0);
}
Run Code Online (Sandbox Code Playgroud)

如果事件出现在Set上,这怎么可能?

java contains equals set compareto

1
推荐指数
1
解决办法
223
查看次数

如何使用java向SQL发送日期和时间

我在数据库中调用存储过程.它的两个参数需要sql日期格式的日期和时间.

String x = new SimpleDateFormat("MM-dd-yyyy").format(new Date()) + " 00:00:00 AM";
String y = new SimpleDateFormat("MM-dd-yyyy").format(new Date()) + " 11:59:00 PM";
Date fromDate = null;
Date toDate = null;
try {
   fromDate = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss a").parse(x);
   toDate = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss a").parse(y);
} catch (ParseException ex) {
}
CallableStatement proc_stmt = con.prepareCall("{ call someproc(?,?) }");
proc_stmt.setDate(1, (java.sql.Date) fromDate);
proc_stmt.setDate(2, (java.sql.Date) toDate);
Run Code Online (Sandbox Code Playgroud)

我相信如果我只发送日期(不包括时间),代码可以工作,但它对我没用,因为数据库不能生成正确的结果.当我运行上面的代码时,我得到了

ClassCastException:java.util.Date cannot be cast to java.sql.Date
Run Code Online (Sandbox Code Playgroud)

有解决方案吗

java sql time date

1
推荐指数
1
解决办法
9179
查看次数

NodeJS中的高性能视频文件服务器

我想在NodeJS中构建一个高可用性和高性能的视频文件服务器和流视频.基本上,我想知道:

  1. 在NodeJS中创建视频文件服务器的可能方法有哪些.
  2. 它会管理很多并发请求吗?由于这是一个视频文件,因此每个请求都需要时间来完全解决.
  3. 是否还有其他可能使用其他静态文件服务器.

请告诉我如何走上正确的道路.

video video-streaming node.js

1
推荐指数
1
解决办法
1700
查看次数

将java中控制台的输出写入文本文件

我想在一个文本文件中显示我的Console的输出.

public static void main(String [ ] args){
    DataFilter df = new DataFilter();   
    df.displayCategorizedList();
    PrintStream out;
    try {
        out = new PrintStream(new FileOutputStream("C:\\test1.txt", true));
        System.setOut(out);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
Run Code Online (Sandbox Code Playgroud)

我在屏幕上正确得到了我的结果,但没有得到文本文件?测试文件是生成但是它是空的?

java

0
推荐指数
1
解决办法
5146
查看次数

C++,我做错了什么?

我试图询问用户10岁学生的年龄,如果他们输入小于0或大于18的任何东西,我希望它将该值更改为0.

我做错了什么?

#include <iostream>
using namespace std;
int main()
   int age [10];
   int TotalAge, AverageAge;

   for (int i = 0; i < 10; i++) 
   {
     cout << "please enter the age of students:";
     cin >> age[i]; 

     if age[i] < 0 || age[i] > 
     cout << "An error was detected in your input, invalid age"; // print 
     age[i] = 0;
     TotalAge += age[i]; // total age is the sum of age
     AverageAge = TotalAge / 10; 
     cout << "Average age of …
Run Code Online (Sandbox Code Playgroud)

c++

-8
推荐指数
1
解决办法
199
查看次数